C#正则表达式

1.参考地址 :C# 正则表达式大全 - 狼牙者.net - 博客园 (cnblogs.com)

string connection = "server=.;Database=test;User Id=tom333-444-7876;password=a123;";
      Regex reg = new Regex("[^s]\\w*");
      Regex regCellphone = new Regex("(\\d{3}-){2}\\d{4}");
      Regex regThreeNumber = new Regex("\\d{3}");
      Match match = reg.Match(connection);
      Match matchPhone = regCellphone.Match(connection);
      //多个匹配项
      MatchCollection matchThreeNumber = regThreeNumber.Matches(connection);
   //替换所有的
   var d = regThreeNumber.Replace(connection,"000");
var result = match.Groups;

 

posted @ 2021-07-16 14:32  留下成长的足迹  阅读(20)  评论(0编辑  收藏  举报