regEx headaches...
Posted: Wed Apr 16, 2003 9:33 am
I am writing a template-class (yeah I know there are 100.000 out there, but that's not what I want) and am making use of regular expressions.
After some initial successes, I've hit a wall. A solid granite wall.
I want to have conditional clauses like IF in there and ended up using the HTML-comment tag as a delimiter "<!--" and "-->" (I tried curly brackets with exclamation mark but nothing worked).
My regEx looks like this:
Anyone know how I can get the regEx to parse the above code correctly?
After some initial successes, I've hit a wall. A solid granite wall.
I want to have conditional clauses like IF in there and ended up using the HTML-comment tag as a delimiter "<!--" and "-->" (I tried curly brackets with exclamation mark but nothing worked).
Code: Select all
<!--IF relatedNews relatedNews="<TR>
<TD class='red'><IMG src='../graphix/blank.gif' width='5' height='1' alt='' border='0'>
</TD>
<TD class='relatedNews' bgcolor='#FFFFFF' valign='top' nowrap><STRONG>In the News</STRONG>
</TD>
</TR>"-->Code: Select all
<?php preg_match_all("/\<!--IF.?([\w])(="[.*])?"--\>/",$temp,$matches, PREG_PATTERN_ORDER);
?>