Regular expression in delphi 7

4

I'm new to programming in Delphi 7, as well as regular expressions.

Delphi 7 because in the company I'm working on, for other reasons, they have to use Delphi 7.

I need to work with regular expressions, someone knows some way. From what I read, there's a library for it, could anyone give me a map?

    
asked by anonymous 31.03.2015 / 03:10

1 answer

2

For versions prior to XE, there are alternatives like TRegExpr that is free.

In newer versions of Delphi there is native support , the unit ( unit ) to be used is System.RegularExpressions .

A simple example replacement: p>

function TForm1.ReplaceCC(const Match: TMatch): string;
begin
  i := i + 1;
  Result := InttoStr(i);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  regex: TRegEx;
  input: string;
  myEval: TMatchEvaluator;
begin
  i := 0;
  input := Edit1.Text;
  regex.Create('cc');
  myEval := ReplaceCC;
  Edit2.Text := regex.Replace(input, myEval);
end;

There is also the open source library System.RegularExpressionsCore.TPerlRegEx implementing regular expressions compatible with Perl .

    
31.03.2015 / 03:44