We have a preg_replace call to take links such as
and convert them into html links. This works well but we are having a problem with it. If the link has a trailing . or ) it is added to the link:
http://www.site.com.
(http://www.site.com)
I have a very difficult time with regex and I am hoping someone can point me into the right direction to ignore the trailing . or ) if it exists
Here is the code:
$stext = preg_replace("/(?<!href=\\")((http|ftp)+(s)?:\\/\\/[^<>\\s]+)/i", "<a href=\\"\\\\0\\" target=\\"_blank\\">\\\\0</a>",$stext);