2018年4月29日

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

摘要: \d 匹配数字 0-9 代码示例 string s = Console.ReadLine(); string pattern = @"^\d*$"; //\d 代表0-9的数字 ^表示以数字开头 $表示以数字结尾。*表示0~n个字符。 bool isMatch = Regex.IsMatch(s, 阅读全文

posted @ 2018-04-29 00:58 雪域凌晨 阅读(84) 评论(0) 推荐(0) 编辑

学习正则表达式定位元字符 ^ 和 $

摘要: ^ 字符用于匹配一个字符串的开始位置,代码例子 string s = "I am a blue cat."; string res= Regex.Replace(s, "^", "开始"); Console.WriteLine(res); Console.ReadKey(); 输出结果是 $ 定位元 阅读全文

posted @ 2018-04-29 00:19 雪域凌晨 阅读(205) 评论(0) 推荐(0) 编辑

导航