GeekZilla
URL Regular Expression
string pattern = @"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)"
Paul is the COO of kwiboo ltd and has more than 20 years IT consultancy experience. He has consulted for a number of blue chip companies and has been exposed to the folowing sectors: Utilities, Telecommunications, Insurance, Media, Investment Banking, Leisure, Legal, CRM, Pharmaceuticals, Interactive Gaming, Mobile Communications, Online Services.
Paul is the COO and co-founder of kwiboo (http://www.kwiboo.com/) and is also the creator of GeekZilla.
Comments
				    Timoteo
				    said:
				    
			    
			    Terrific. Thanks.
				    Aung
				    said:
				    
			    
			    Thanks
				    Shadi Abu Hilal
				    said:
				    
			    
			    Thanks man ![]()
				    Stephen G.
				    said:
				    
			    
			    Excellent, this is a great help.
One suggestion though... be careful to escape the dash "-" character when using it in character class definitions []. Since a raw "-" is used to define a range (e.g., [A-Z]), you may want to escape the dash used in your Reg Ex.
The class [\w\d:#@%/;$()~_?\-=\\\.&] will unintentionally match all of the characters between and =. The following includes an escaped dash:
string pattern = "((https?|ftp|gopher|telnet|file|notes|ms-help)%/;$()~_?\\-=\\\.&]*)"
(//)|(\\\\))[\w\d:#
				    Michael
				    said:
				    
			    
			    Don't use the regex from Stephen G.
Url's with "-" are splitted with this code.
				    Peter
				    said:
				    
			    
			    I thing it is not good, because when you specify url like this:
http://www.google.com:xxx (where :xxx represents port number) this must failed because xxx is not number (for port), but using this regex returns true.
				    Yahya
				    said:
				    
			    
			    Hellow Admin!!!!!!!!!!!
Thnks for presentation of bestandeveruseful site
				    Bonzo
				    said:
				    
			    
			    This Regex work fine for me:
^(https?://)?(([0-9a-z_!~'().&=$%-]: )?[0-9a-z_!~'().&=$%-]@)?(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z_!~'()-]\.)([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.[a-z]{2,6})(:[0-9]{1,4})?((/?)|(/[0-9a-z_!~*'().;?
&=$,%#-])/?)$
				    Sameer
				    said:
				    
			    
			    Thanks...
				    Ryan Timoney
				    said:
				    
			    
			    Kiiind of obscure but a note to anyone using this with cURL: There's a security hole in versions 5.11 to and including 7.19.3 where a 'file' URL can be exploited to manipulate server files and run commands as the webuser. http://curl.haxx.se/docs/adv_20090303.html
				    KS
				    said:
				    
			    
			    Thanks a lot man....
				    
				    said:
				    
			    
			    "((https?|ftp|gopher|telnet|file|notes|ms-help)%/;$()~_?\-=\\\.&]*)"
(//)|(\\\\))[\w\d:#
if this right then thanks otherwise write in detailed not in short form
				    anirudha mathur
				    said:
				    
			    
			    "((https?|ftp|gopher|telnet|file|notes|ms-help)%/;$()~_?\-=\\\.&]*)"
(//)|(\\\\))[\w\d:#
update your blog or write in detail not in short
blah nlah blah
				    Andone
				    said:
				    
			    
			    thanks!
				    asp
				    said:
				    
			    
			    <i>...and</i> for the url starting with <em>"/site.php?......"</em> ?
				    amit jha
				    said:
				    
			    
			    great! great!! great!!!
				    mapemape
				    said:
				    
			    
			    Dude,
I put that regular expression in my code and when I put "http://www." (without double quotes) is valid based on that regular expression. It shouldn't be valid..
				    Hiren 
				    said:
				    
			    
			    Hello sir, some times it includes
</a
when we find matches.
				    rahman
				    said:
				    
			    
			    thank you paul
				    simon
				    said:
				    
			    
			    Why not use [^//s] (non blank character) ?
				    Junaid
				    said:
				    
			    
			    ok.... good it is
				    Alex Barac
				    said:
				    
			    
			    This REGEX validates a link like "http://www.asdf", I'm sure this is not supposed to happen...
				    http://watchavideo.NET
				    said:
				    
			    
			    thank you, was looking for this for my site
				    mayasakthi
				    said:
				    
			    
			    Thanks good
				    novel
				    said:
				    
			    
			    what is the example of http regular expression
