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?
Find and Unlink URLs
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Fiddly. Negative Lookbehind perhaps?
Code: Select all
echo preg_replace('/(?<!\s)title=/i', 'title/', $link);