1 //FileStream fs = new FileStream(@"C:\Users\Alex\Desktop\Task.txt", FileMode.Open, FileAccess.Read);
2 //StreamReader sr = new StreamReader(fs);
3
4 #region "Read Content"
5 StreamReader sr = new StreamReader(@"C:\Users\Alex\Desktop\Task.txt", Encoding.GetEncoding("gb2312"));
6 string content = sr.ReadToEnd();
7
8 sr.Close();
9
10 Console.WriteLine(content);
11
12 Regex rx = new Regex(@"1[3-8]\d{9}");
13 MatchCollection matches = rx.Matches(content);
14 Console.WriteLine(matches.Count);
15 foreach (Match match in matches)
16 {
17 Console.WriteLine(match.Value);
18 }
19 Console.ReadKey();
20 #endregion
匹配手机号
时间: 2024-10-10 14:23:35