RegEx.Exec

Top  Previous  Next

 

Syntax

function RegEx.Exec(RegEx: pointer; InputStr: string): boolean

 

Alternative Names

RE.Exec
ibec_re_Exec

 

Description

Attemps to find matches in the text.

 

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

 

The InputStr is the text that will be searched for matches.

 

Returns TRUE is a match has been found, FALSE otherwise. The actual matched text can be acquired using RegEx.Match.

 

An easier way to find all matches is RegEx.FindMatches.

 

See also

RegEx.Create
RegEx.Match
RegEx.Free
RegEx.ReplaceMatches

 

Example

execute udsblock 

as

begin

  /* create the object with an expression */

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

 

  try

    /* find matches in a text */

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

    while (Res <> __FALSE)

    do begin

         /* a match has been found, display it */

     email = RegEx.Match(re, 0);

         GUI.ShowMessage('Found e-mail: ' || email);

 

         /* attempt to find the next match */

         Res = RegEx.ExecNext(re);

       end

  finally

    RegEx.Free(re);

  end

end;