Hello, I'm using the following pattern to replace URLs into links: /http:\/\/([a-zA-Z0-9\?\&\%\.\;\:\/\=\+\_\-]*)/is It works, but it also replaces the links that are already there in the html, thus breaking them... <a href="http://someurl.com"> some url </a> http://anotherone.com Code (markup): Both the http//) get replaced, and first one breaks... How do I change it so it neglects the ones with (") sign in suffix and prefix? "http://someurl.com" does not get replaced. I don't want to use \s because sometimes the URL might be followed by a < or sign or a \r\n etc... Thanks
see if this works : $modified_str = preg_replace('/(?<!http:\/\/)(www.[-a-zA-Z0-9@:%_\+.~#?&\/=]+)/i', '<a href="http://\1">\1</a>', $str) Code (markup):