Posted By

kat on 06/18/10


Tagged

regex url


Versions (?)

Url regex


 / Published in: C#
 

http://www.osix.net/modules/article/?id=586

  1. private static readonly string IsUrlRegex =
  2. "^(https?://)?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" //user@
  3. + @"(([0-9]{1,3}\.){3}[0-9]{1,3}" // IP- 199.194.52.184
  4. + "|" // allows either IP or domain
  5. + @"([0-9a-z_!~*'()-]+\.)*" // tertiary domain(s)- www.
  6. + @"([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." // second level domain
  7. + "[a-z]{2,6})" // first level domain- .com or .museum
  8. + "(:[0-9]{1,4})?" // port number- :80
  9. + "((/?)|" // a slash isn't required if there is no file name
  10. + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";

Report this snippet  

You need to login to post a comment.