2024-11-19《学习定位点与限定符》

定位点

image-20221014161720248

分组构造

image-20221014161741970

限定符

image-20221014161759146

反向引用构造

image-20221014161821470

备用构造

image-20221014161836941

替换

image-20221014161851926

杂项构造

image-20221014161911024

Regex类

image-20221014161926139

  示例:

  using System;
  using System.Text.RegularExpressions;
   
  namespace RegExApplication
  {
  class Program
  {
  private static void showMatch(string text, string expr)
  {
  Console.WriteLine("The Expression: " + expr);
  MatchCollection mc = Regex.Matches(text, expr);
  foreach (Match m in mc)
  {
  Console.WriteLine(m);
  }
  }
  static void Main(string[] args)
  {
  string str = "A Thousand Splendid Suns";
   
  Console.WriteLine("Matching words that start with 'S': ");
  showMatch(str, @"\bS\S*");
  Console.ReadKey();
  }
  }
  }
posted @   new菜鸟  阅读(1)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示