interesting problem with preg_replace()
Posted: Thu Jul 18, 2002 12:01 am
so i'm using preg_replace() to parse a template for XML data. my template is a simple string along the lines of...
where the XML tag names are between the %s. my preg_replace call is...
The problem is that it is seeing
(from the url line of the template) and trying to replace that. is there any way to have each percent sign be matched only once?
Code: Select all
$html_tpl = '
<b>%title%</b><br>
<i>%time%</i><br>
<a href="%url%">%url%</a><br>
<br>';Code: Select all
$html = preg_replace('/\%(.+)\%/ie', "$\\1", $html_tpl);Code: Select all
%">%