Jhonjhon_123

Untitled

Feb 4th, 2012
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.61 KB | None | 0 0
  1. procedure RegExMatchAll(Pattern: String; Subject: String; out Matches: TMatches);
  2. var D, sD: integer; RegEx: TRegEx; RegGroupColl: TGroupCollection; RegColl: TMatchCollection;
  3. begin
  4.  
  5.   RegEx := TRegEx.Create(Pattern);
  6.   RegColl := RegEx.Matches(Subject);
  7.  
  8.   SetLength(Matches, RegColl.Count); // Numero de coincidencias [array [X]]
  9.  
  10.   for D := 0 to RegColl.Count - 1 do begin
  11.     RegGroupColl := RegColl.Item[D].Groups;
  12.     SetLength(Matches[D], RegGroupColl.Count); // Numero de grupos [array [D][sD]]
  13.     for sD := 0 to RegGroupColl.Count - 1 do Matches[D][sD] := RegGroupColl.Item[sD].Value;
  14.   end;
  15.  
  16. end;
Advertisement
Add Comment
Please, Sign In to add comment