Re: Error in BTML parser 2

From: Date: Mon, 13 Oct 2003 14:32:57 +0000
Subject: Re: Error in BTML parser 2
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-165990@lists.php.net to get a copy of this message
Yes! It works!!! This is also an good beginner-HTML. If you have improvements then i like it from you to post them in an reply or email me. Regards, Bas "Curt Zirzow" <php-general@zirzow.dyndns.org> wrote in message news:20031013142320.GH51024@bagend.shire... > * Thus wrote Bas (bas_timmer49@hotmail.com): > > This error is not so stupid as a deleted closing ". > > > > Okay, for all of you who missed my code here is it again: > > > > > read-tags.php > > --- > > <?php > > // Tag Parser v1.1 > > // v1.0 First release(not working) > > // v1.1 Edited: > > // Uses Regular Expressions > > function parseTags($file) { > > /* readfile... here */ > > $filedata = file_get_contents($file); > > $tag_match = "!<bttag=(\w*)>\s*([^<]*)\s*</bttag>!is"; > > Mabey I should have explained the regex. The tagname (the value in > matches[1][$] can only be a word character (\w*) and the value > ($matches[2[$i] inside the tag will find all characters upto the > </bttag> except for the < character. > > Also do note, the '\s*' before and after the (.*?), this will force > the value returned without leading or trailing white space. > Depending on your situation this might not be desireable. > > [...] > > > > <bttag=text> > > Welcome to my BTML page!!! This is an experimentally version of HTML!!! > > <br>Bye!!! > > </bttag> > [..] > > > > Run btml.php?name=test.btm and you will get this error plus good output: > > > > Notice: Undefined index: text in C:\pub\include\btml.php on line 15 > > According to my description above, the code will ignore anything > that has a < character within the tags. so to allow this you'll need to > change the regex to something like: > > $tag_match = "!<bttag=(\w*)>\s*(.*?)\s*</bttag>!is"; > > this will force it to match *anything* between the tags, except for > leading and trailing white space. > > > Curt > -- > "My PHP key is worn out" > > PHP List stats since 1997: > http://zirzow.dyndns.org/html/mlists/

« previous php.general (#165990) next »