TPerlRegExMatchedLength (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example uses the TPerlRegEx MatchedLength property. This example assumes you placed a TLabel and a TPerlRegEx on a form.

Code

with PerlRegEx1 do begin
  Subject := 'Rating: AAA';
  RegEx := 'A+';  // Matches the first occurence of 'A', including any A's that may follow right after it
  if Match then Label1.Caption := 
    'You have been rated with ' + IntToStr(MatchedLength) + 'A''s'
  else
    Label1.Caption := 'You have a poor rating';
end;

Uses