PHP - Replacing ereg with preg
2 answers
There seems to be no need for regular expressions.
simple str_replace will do:
$cleaned = str_replace ('<b>', '<strong>', $unCleaned);
If you need more complex replacements like attribute validation, you can do:
$cleaned = preg_replace('/<b(\s[^>]*)?>/', '<strong\\1>', $unCleaned);
But this is by no means ideal; something like <div title="foo->bar"></div>
will break the regex.
+9
source to share