Satyajit Kadam

Satyajit Kadam

  • NA
  • 1
  • 6.4k

Validate url sing regular expression (url may contains ip address or domain name)

Aug 7 2012 8:00 AM
Hello,

I am using below pattern in regular expression for validating url but this patterns returns false even when url contains ip address instead of domain name
 
string regExPattern = @"^(((ht|f)tp(s?))\://)?(www.|[a-zA-Z].)[a-zA-Z0-9\-\.]+\.(com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk)(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$";

I want pattern who returns true for below links

http://192.168.1.244/default.aspx

http://www.home.com/default.aspx

http://192.168.1.244:8080/default.aspx

Please give solution as soon as possible.

Thanks in advance

Answers (1)