求一个正确的网址正则表达式,急   

解决方案 »

  1.   

      string input = @"http://torch.2008.sina.com.cn/jz/other/2008-04-11/040666651.shtml\1";
            string pattern = @"^http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?$";
            if (Regex.IsMatch(input, pattern))
            {
                Response.Write("成功");
            }
            else
            {
                Response.Write("失败");
            }
      

  2.   

     string input = @"Http://torch.2008.sina.com.cn/jz/other/2008-04-11/040666651.shtml";
            string pattern = @"^htp(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?$";
            if (Regex.IsMatch(input,pattern,RegexOptions.IgnoreCase))
            {
                Response.Write("成功");
            }
            else
            {
                Response.Write("失败");
            }不区分大小写
      

  3.   

    ^(\w+:\/\/)?([^\ .]+)(\.[^/: ]+)(:\d*)?([^# ]*)$赋值时c#使用@前辍,或者不使用@前辍但对\进行转义