Right now
I’m using
$content = preg_replace('@(https?://([-\w\.]+)+(:\d+)?((/[\w/_\.%\-+~]*)?(\?\S+)?)?)@', '<a href="$1" target="_blank">$1</a>', $content);
for replace url with links but it doesn’t works with some symbols like # and so many other
and also i want that if the content appears like this
<a href="http://www.abc.com/">http://www.abc.com/</a>
then the preg_replace skip this otherwise it will duplicate the same and produces wrong result.
Why not just look for anything starting with http:// or https:// up until any whitespace character?
That is obviously pretty forgiving, the only problem is that you might get some false positives.