Page 1 of 1

Linking non-linked URLs

Posted: Tue Jun 15, 2010 5:30 pm
by Cirdan
In my forum, I'd like to automatically link any URLs in the posts that are not already linked. I have this regex I found...

Code: Select all

@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.\-]*(\-\?\S+)?)?)?)@
But I can't figure out how to make it ignore cases where there are quotes at the end. I have tried putting [^"\'] at various places within the regex, but that doesn't work. I also tried putting [\s\r\n], hoping it would find a blank space or new line and count that as a non-linked url, but that didn't work either. Any help would be much appreciated!

Re: Linking non-linked URLs

Posted: Wed Jun 16, 2010 9:36 am
by andyhoneycutt
post an example of what you would like it to find, and what you would like it to avoid, if you would be so kind.

Re: Linking non-linked URLs

Posted: Wed Jun 16, 2010 1:17 pm
by Cirdan
Sure thing. For example if someone puts a url into a forum post like this: http://forums.devnetwork.net/index.php I want it to recognize that and automatically make a link out of it. However, if it finds a URL like this:<a href="http://myurl.com" >My URL</a> Then it should ignore it because it's already a link, or because it's a url for an <img> tag.