Need Some Help With Regex:
I want to replace
[url=http://youtube.com]YouTube.com[/url]
with
<a href="http://youtube.com">YouTube.com</a>
the regex
preg_replace("/[url=(.*?)](.*?)[/url]/is", '<a href="$1">$2</a>', $text);
why does this give me:
Warning: preg_replace() [function.preg-replace]: Unknown modifier ‘r’ in C:\Programa\wamp\www\func.php on line 18
You should escape special characters in your regular expression:
I have escaped the
[characters (they specify the start of a character class) and the/character (it specifies the boundaries of the regular expression.)Alternatively (for the
/character) you can use another boundary character:You still have to escape the
[characters, though.