TPerlRegExMatchAgain (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example uses the TPerlRegEx MatchAgain method.

Code

procedure TForm1.Button1Click(Sender: TObject);
var I: Integer;
begin
  with PerlRegEx1 do begin
    RegEx := UTF8String(Edit1.Text);
    Subject := UTF8String(Edit2.Text);
    if Match then begin
      I := 1;
      while MatchAgain do I := I + 1;
      ShowMessage(Format('The regular expression matched the subject string %d times.', [I]));
    end
    else
      ShowMessage('The regular expression did not match the subject string at all.');
  end;
end;

Uses