RegEx.Create

Top  Previous  Next

 

Syntax

function RegEx.Create(Pattern: string): pointer

 

Alternative Names

RE.Create
ibec_re_Create

 

Description

Creates a Regular Expression object with the given pattern. This object can then be used in additional calls to match and replace text.

 

The Pattern is the regular expression that will be used to match text in later calls.

 

The Return Value is a pointer to the RegEx object. You need to call RegEx.Free to release resources.

 

See also

RegEx.Exec
RegEx.Match
RegEx.Free

 

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;