条件
整数0到6位
可以没有小数
如果有小数
一个小数点,0到2位小数的正则

解决方案 »

  1.   

    Regex rx = new Regex(@"^([1-9]\d{0,5}|[0])(\.\d{1,2})?$");测试如下:
     Regex rx = new Regex(@"^([1-9]\d{0,5}|[0])(\.\d{1,2})?$");
                string str = Console.ReadLine();
                while (str != "exit")
                {
                    if ((rx.Match(str)).Success)
                    {
                        Console.WriteLine("yes");
                    }
                    else
                    {
                        Console.WriteLine("no");
                    }
                    str = Console.ReadLine();
                }
      

  2.   

    @"^\d{1,6}(\.\d{1,2})?$" 
    这个就行 我试过了 呵呵 
    liujia_0421(SnowLover) 
    自己把自己给推翻了 
    哈哈