在C#中使用正则表达式

在C#中使用正正则表达式:

  首先:using System.Text.RegularExpressions;

  然后就是实例化Regex类:Regex r = new Regex("(^1\d{10}$)|(^0\d{10,11}$)");   //验证手机号

  r.isMatch("123");  //符合正则表达式 ? true : false;

原文地址:https://www.cnblogs.com/lh-V/p/3397621.html