Code string x ="0"; string y ="0.23"; string z ="100"; string a ="100.01"; string b ="9.9"; string c ="99.9"; string d ="99."; string e ="00.1"; Regex r =new Regex(@"^\+?((100(.0+)*)|([1-9]?[0-9])(\.\d+)*)$"); Console.WriteLine("x match count:"+ r.Matches(x).Count);//1 Console.WriteLine("y match count:"+ r.Matches(y).Count);//1 Console.WriteLine("z match count:"+ r.Matches(z).Count);//1 Console.WriteLine("a match count:"+ r.Matches(a).Count);//0 Console.WriteLine("b match count:"+ r.Matches(b).Count);//1 Console.WriteLine("c match count:"+ r.Matches(c).Count);//1 Console.WriteLine("d match count:"+ r.Matches(d).Count);//0 Console.WriteLine("e match count:"+ r.Matches(e).Count);//0 //匹配0到100的数。最外层的括号内包含两部分“(100(.0+)*)”,“([1-9]?[0-9])(\.\d+)*”,这两部分是“OR”的关系,即正则表达式引擎会先尝试匹配100,如果失败,则尝试匹配后一个表达式(表示[0,100)范围中的数字)。