Page 1 of 1

extracting certain characters

Posted: Wed Feb 21, 2007 5:12 pm
by mzfp2
Hi,

Hope someone is able to help me with a problem I have run into with a regular expression which I thought was working perfectly for a while!

The expression :

preg_match_all("#<\#if:.*?>#s", $Template, $StartTags, PREG_OFFSET_CAPTURE);

This fetches custom tags from a html file which appear in the following format

<#if:some_text>

pretty simple and work in all cases where some_text is normal text, however when it contains the character '>' (ie html tags such as <b>) it fails too extract the text,

is there a way to modify the pattern I am using to fetch these html tag characters as well? bearing in mind '>' denone the end of custom tag as the expression shows.

Thanks for any help on this!

Posted: Wed Feb 21, 2007 9:31 pm
by feyd
Nesting is not a simple subject to handle. It's a shame your tag isn't a bit more unique (like a comment tag for example.) While it's possible to handle basic nesting in a single query, if you want it to work for all possible occurrences, it's best to use a string parser then.