while problems

From: Date: Mon, 18 Dec 2000 06:47:37 +0000
Subject: while problems
Groups: php.general 
Request: Send a blank email to php-general+get-30838@lists.php.net to get a copy of this message
Hi Guys, I am trying a do a regular expression search on the following piece of code: $content = "<a name=\"top\"></a><span class=\"heading\">Why E Procurement</span><br>&nbsp;<br><a href=\"#overview\">Overview</a> | The OBU Standard"; I am taking any instances of <a name="*"></a> and replacing it with {anchor | *}. Also, taking any instances of <span class=heading>*</span> and replacing it with {heading}*{/heading}, taking <br>&nbsp;<br> and replacing it with \n\r, taking any instance of <a href="*1">*2</a> and replacing it with {link | *1}*{/link}. This all works fine and everything is great. But if I add other <a href="">'s to the code ie: $content = "<a name=\"top\"></a><span class=\"heading\">Why E Procurement</span><br>&nbsp;<br><a href=\"#overview\">Overview</a> | <a href=\"#obu\">The OBU Standard</a>"; It screws up. So I put in a while loop (below) to try and catch all instances of it but it doesn't seem to be looping. $pat = "<a href=\"#(.+)\">(.+)</a>"; while (ereg($pat, $content)) { $content = ereg_replace($pat, "{link | #\\1}\\2{/link}", $content); } Does anybody have any ideas or a better way to do it? Any thoughts, tips, ticks would be very useful and much appreciated. thanks Scott.

« previous php.general (#30838) next »