I'm using following regex to find and replace any external url in my content and convert it to active link.
$content = preg_replace('#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is', '\\1<a href="/_goto.php?exturl=http://\\2" target="_blank" class="external" rel="nofollow">\\2</a>', $content);
$content = preg_replace('/<a(.*?)>www./', '<a$1>', $content);
It works fine but don't catch urls between <li>
or other tags.
Ex: <li>www.google.com</li>
How can I modify it to work in that cases? Thanks