PHP Regex word boundary pattern ignores / in urls
Posted: Wed Jun 17, 2009 4:24 pm
hi, I'd like to correct the following REGEX pattern so that it no long effects urls or text proceeded by a forward slash /
example, the following preg_replace will take the string
reviews/payroll-relief-from-accountantsworld.html
payroll
and assuming payroll is the needle, it will return
reviews/<a href = "blah">payroll</a>-relief-from-accountantsworld.html <a href = "blah">payroll</a>
how can i keep word boundary from ignoring the / slash when searching for substrings? thanks
example, the following preg_replace will take the string
reviews/payroll-relief-from-accountantsworld.html
payroll
and assuming payroll is the needle, it will return
reviews/<a href = "blah">payroll</a>-relief-from-accountantsworld.html <a href = "blah">payroll</a>
how can i keep word boundary from ignoring the / slash when searching for substrings? thanks
Code: Select all
$words[$i] = '/\b'.$words[$i].'\b/';
$content = preg_replace($words, $Links, $content);