如题 
要求只能输入类似 http://127.0.0.1/test/即 http://IP/文件夹/ 

解决方案 »

  1.   

    楼主,难道先前的答案对你没有用处吗?http://topic.csdn.net/u/20090305/08/f9ced1ab-d04f-48b8-b95c-cf3349ec4a80.html
      

  2.   

    ^\d+$  //匹配非负整数(正整数 + 0) 
    ^[0-9]*[1-9][0-9]*$  //匹配正整数 
    ^((-\d+)|(0+))$  //匹配非正整数(负整数 + 0) 
    ^-[0-9]*[1-9][0-9]*$  //匹配负整数 
    ^-?\d+$    //匹配整数 
    ^\d+(\.\d+)?$  //匹配非负浮点数(正浮点数 + 0) 
    ^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$  //匹配正浮点数 
    ^((-\d+(\.\d+)?)|(0+(\.0+)?))$  //匹配非正浮点数(负浮点数 + 0) 
    ^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$  //匹配负浮点数 
    ^(-?\d+)(\.\d+)?$  //匹配浮点数 
    ^[A-Za-z]+$  //匹配由26个英文字母组成的字符串 
    ^[A-Z]+$  //匹配由26个英文字母的大写组成的字符串 
    ^[a-z]+$  //匹配由26个英文字母的小写组成的字符串 
    ^[A-Za-z0-9]+$  //匹配由数字和26个英文字母组成的字符串 
    ^\w+$  //匹配由数字、26个英文字母或者下划线组成的字符串  
    ^[a-zA-z]+://匹配(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$  //匹配url 
    看看这些能拼成你想要的吗
      

  3.   


    using System;
    using System.Text.RegularExpressions;namespace CSDN
    {
        class Application
        {
            static void Main(string[] args)
            {
                string input = "http://127.0.0.1/test/";
                bool b = Regex.Match(input, @"^http://\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/\w+/$", RegexOptions.IgnoreCase).Success;
            }
        }
    }