反向引用组-C#入门经典
反向引用组string speech = "Four score and seven years"; pat = @"(\b[a-zA-Z]+\b)\s\1"; //pat = @"(?\b[a-zA-Z]+\b)\s\k< repeatand>"; MatchCollection mc = Regex.Matches(speech, pat); foreach (Match mt in mc) { Console.WriteLine(mt); //Console.WriteLine(mt.Groups[repeatand]); }
4.81MB
文件大小:
评论区