Page 1 of 1

Find and Unlink URLs

Posted: Tue Feb 14, 2006 4:02 pm
by kirk7880
I used str_replace to rewrite a few urls, however, certain url parameters contain similar names as "a href" parameter.

To be clear the url have "title" in the param.... as you know, href's tags sometimes contain (a href=domain title=xxx>)

I only rewrote a portion of the url

http://www.xxx.com/xxx.php?search=xxx&title=xxx

$buffer = str_replace("&title=", "/title/", $buffer);

The problem is that this rewrite's the title tag in the hyperlinks. (from <a href=xxx title=xxx> to <a href=xxx title/xxx>)

How can i write this rule so the "<a href" title tag is not affected?

Posted: Tue Feb 14, 2006 4:08 pm
by Chris Corbyn
Fiddly. Negative Lookbehind perhaps?

Code: Select all

echo preg_replace('/(?<!\s)title=/i', 'title/', $link);