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

分组构造

限定符

反向引用构造

备用构造

替换

杂项构造

Regex类

示例:
| 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(); | |
| } | |
| } | |
| } |
浙公网安备 33010602011771号