I created a regular expression that reads a string and transforms found url’s into HTML links. I wanted to exclude the dot at the end of a line (containing the text link) but it also excludes the dot inside the text link (like in http://www.website.com/page.html.) The end dot here should be excluded but not the .html. This is my regex:
$text = preg_replace("#(^|[\n \"\'\(<;:,\*])((www|ftp)\.+[a-zA-Z0-9\-_]+\.[^ \"\'\t\n\r< \[\]\),>;:.\*]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $text);
How would one do that?
Thanx! Tom
Change your RegEx to this
or this
Explanation
Hope this helps.