用正则式做什么,简单的一个判断就行了

解决方案 »

  1.   

    using System;using System.Text.RegularExpressions;
    namespace ConsoleApplication4
    {
       /// <summary>
       /// Class1 的摘要说明。
       /// </summary>
       class Class1
       {
          /// <summary>
          /// 应用程序的主入口点。
          /// </summary>
          [STAThread]
          static void Main(string[] args)
         {

    Regex reg=new Regex("[0-9]{1,}");
    string str="12";

    if(str.Length<=4)
    {
    Match m=reg.Match(str);
             if(m.Success)
    {
    Console.WriteLine(" your input {0} is Success",str);
    }
    }
    str="123456";
    if(str.Length<=4)
    {
    Match m=reg.Match(str);
             if(m.Success)
             {
                   Console.WriteLine(" your input {0} is Success",str);
              }
              }
    Console.ReadLine();
           }
         }
    }