TPerlRegExNamedGroup (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example uses the TPerlRegEx NamedGroup method.

Code

procedure TForm1.Button1Click(Sender: TObject);
begin
  with PerlRegEx1 do begin
    RegEx := '(?P<firstname>Joe|Jack|William|Avarell) did it';
    Subject := 'The sheriff told us that Joe did it.';
    if Match then
      ShowMessage('Wanted: ' + Groups[NamedGroup('firstname')]);
  end;
end;

Uses