in my website i want to replace links with some other link like this
www.abc.com
or http://abc.com
will be replaced with
http:/
"/\[url]www|http://.([^'\"]*)\[\/url]/iU",
^ ^^ ^
You either need to escape the two //
in the middle to \/\/
, or, better, use different delimiters for the regex:
"~\[url]www|http://.([^'\"]*)\[/url]~iU",
There is few ways to solve that
Escaping "/"
$search_array = array(
"/\[url]www|http:\/\/.([^'\"]*)\[\/url]/iU",
"/\[url]([^'\"]*)\[\/url]/iU",
"/\[url=www|http:\/\/.([^'\"\s]*)](.*)\[\/url]/iU",
"/\[url=([^'\"\s]*)](.*)\[\/url]/iU"
);
Or using different regexp seperator like "#"
$search_array = array(
"#\[url]www|http://.([^'\"]*)\[\/url]#iU",
"#\[url]([^'\"]*)\[\/url]#iU",
"#\[url=www|http://.([^'\"\s]*)](.*)\[\/url]#iU",
"#\[url=([^'\"\s]*)](.*)\[\/url]#iU"
);