Regex WTF???
Posted: Fri Feb 01, 2008 11:58 pm
I have the following simple regex:
It actually works after some struggle...
Problem is...I don't understand how it's working...I get that it's matching two tags...but why does the non-alphanumeric have to follow? Shouldn't it be whitespace - if anything?
Secondly, I have tried to adapt this regex so that both opening and closing tags are replaced with asterisks using the following:
It works - sorta!!! But it chops off everything until end of line on the closing tag...
Help
Cheers
Code: Select all
$content = preg_replace('/<\/?((b|strong)\W[^>]*)>/is', '*', $content);Problem is...I don't understand how it's working...I get that it's matching two tags...but why does the non-alphanumeric have to follow? Shouldn't it be whitespace - if anything?
Secondly, I have tried to adapt this regex so that both opening and closing tags are replaced with asterisks using the following:
Code: Select all
$content = preg_replace('/<(\/?((b|strong)\W[^>]*))>/is', '*', $content);Help
Cheers