TRegexMatch

From SCAR Divi Manual
Revision as of 15:30, 4 July 2011 by Freddy (talk | contribs) (Created page with "==Definition== <source lang="scar" lines="false"> TRegexMatch = record MatchedText: AnsiString; Offset: Integer; Length: Integer; end; </source> ==Availability== SCAR Divi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Definition

TRegexMatch = record
  MatchedText: AnsiString;
  Offset: Integer;
  Length: Integer;
end;

Availability

SCAR Divi 3.25 > Current

Description

A structured type which holds a regex match. MatchedText holds the text that was matched, Offset holds the offset where the match was found and finally Length holds the length of MatchedText.

Example

var
  Matches: TRegexMatchArray;
  i: Integer;

begin
  PregMatchEx('/World\! (\d+)/', 'Hello World! 125', Matches);
  for i := Low(Matches) to High(Matches) do
    WriteLn('"' + Matches[i].MatchedText + '" at ' + IntToStr(Matches[i].OffSet) +
      ' with length ' + IntToStr(Matches[i].Length));
end.

Output:

"World! 125" at 7 with length 10
"125" at 14 with length 3

See Also