I've come so close to a working solution to my problem, just need help to get the final little bugs out.
Users create comments, which can contain a reference to a link within the comment.
My current preg_replace to determine if there is a url so it can be turned to a link:
Code: Select all
$msg = preg_replace("/([^A-z0-9?])(http|ftp|https)([\:\/\/])([^\\s]+)/"," <a href=\"$2$3$4\" ref="nofollow">$2$3$4</a>",$msg);
* example 1:
http://helloworld.com is a great site, check it out. --- does not convert url to a link, something to do with there not being any characters before the url
* example 2: check out http://helloworld.com, it's a great site! --- converts to link BUT the comma is part of the link so it won't work (this also happens if a parenthesis, dash, etc. are connected to the end of the url)
Any help with either or both of these problems would be great, thanks for taking a look!
Brad