TPerlRegExSubject (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example uses the TPerlRegEx Subject property at runtime to match RegEx. Place a TButton and two TEdit on the form, declare a TPerlRegEx as a global variable and instantiate it in initialization code. Also include RegularExpressionsCore in the Uses clause.

Code

procedure TForm1.Button1Click(Sender: TObject);
begin
  with PerlRegEx1 do begin
    Subject := 'I like to hang out at Foo bar';
    RegEx := '([A-Za-z]+) bar';
    Replacement := '\1 is the name of the bar I like';
    if Match then ShowMessage(PerlRegEx1.ComputeReplacement);
  end;
end;

Uses