RegEx.Replace

Top  Previous  Next

 

Syntax

function RegEx.Replace(RegEx: pointer; InputStr: string; ReplaceStr: string): string

 

Alternative Names

RE.Replace
ibec_re_Replace

 

Description

Replaces all matches with the given replacement.

 

RegEx is a previously created Regular Expression object by calling RegEx.Create.

 

The Regular Expression object text will be set to the InputStr.

 

Returns the text of ReplaceStr with back references replaced with any matches found. The Regular Expression object will retain the original text.

 

See also

RegEx.Create
RegEx.Free
RegEx.ReplaceMatches

 

Example

execute udsblock 

as

begin

  re = RegEx.Create('[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+');

  try

    resulttxt = RegEx.Replace(re, 'test m@nu.nl and then some z@example.com and more, @, test. finally fake@web.com', '$0 is the e-mail found');

    GUI.ShowMessage(resulttxt);

  

    resulttxt = RegEx.Replace2(re, 'test m@nu.nl and then some z@example.com and more, @, test. finally fake@web.com', 'nospam@example.com', 1);

 GUI.ShowMessage(resulttxt);

  finally

    RegEx.Free(re);

  end

end;