Forum Moderators: coopster

Message Too Old, No Replies

Match a url

that may or may not have http:// www. etc

         

Tommybs

9:00 am on Jan 12, 2011 (gmt 0)

10+ Year Member



Hi,

I've search the forums and elsewhere on the web, but can anyone think of a good way to match a url that may or may not have been entered with http:// www. etc?

I'm thinking the way to do it is to look for the domain extension and then work back from there ( although I'd be after the full link not just the domain

This is for a user form that's not specifically tied to being a url, it's just a chunk of text, but I want to extract all potential links from it in theory.

If anyone knows anything off hand that would be great. Otherwise an insight into the best way to approach the matching would be appreciated
(I am willing to try the regex by myself first but thought I'd see if any one had good ideas on good way to start this match)

Thanks

T

penders

3:28 pm on Jan 12, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



...to match a url that may or may not have been entered with http:// www. etc?


So, you want to be able to match anything that looks as if it could be a URL, even if it is potentially just a partial match, eg. "example.com"?

Tommybs

3:45 pm on Jan 12, 2011 (gmt 0)

10+ Year Member



yep, my thought was about look for domain and extensions and working out a regex from there. Do you think this is the best start point?