Thursday, July 4, 2024

One of the convenient automations uses a well-known algorithm.

String matching algorithms: 


Void PrintMatch(String text, string pattern) 



Regex r = new Regex(pattern, options); 


Int[] gnums = r.GetGroupNumber(); 


Match m = r.Match(text); 


While (m.Success) 



Group g = m.Groups[gnums[i]]; 


CaptureCollection cc = g.Captures; 


For (int j = 0; j < cc.Count; j++) 



capture c = cc[j]; 


Console.WriteLine(“\t\tCapture{0} = [{1}] Index={2} and Length={3}”, j, c,c.Index, c.Length); 



m = m.NextMatch(); 



}


No comments:

Post a Comment