正则表达式基本语法元字符

\d  匹配数字 0-9 

代码示例

string s = Console.ReadLine();
string pattern = @"^\d*$";
//\d 代表0-9的数字 ^表示以数字开头 $表示以数字结尾。*表示0~n个字符。
bool isMatch = Regex.IsMatch(s, pattern);

Console.WriteLine(isMatch);
Console.ReadKey();

 

posted on 2018-04-29 00:58  雪域凌晨  阅读(84)  评论(0编辑  收藏  举报

导航