StrRegexFindFirst Function

Action

Creates an iterator over matched portions and stores the first matching substring into sTarget.

Include file

Kernel.bdh

Syntax

StrRegexFindFirst( in  hRegex  : number,
                   in  sSource : string,
                   out sTarget : string,
                   in  iLen    : number ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
hRegex Valid handle to a compiled regular expression. This handle must have been generated with a previous call to StrRegexCompile.
sSource String to be matched by the regular expression.
sTarget String which receives the result of the substitution string.
iLen Size of sTarget.

Example

transaction TMain
var
  s       : string;
  sResult : string;
  hRegex  : number;
begin
  s := "page1 alpha beta omega page4 page2 gamma page3";
  StrRegexCompile(hRegex, "page[0-9]");

  if (StrRegexExecute(hRegex, s)) then
    StrRegexFindFirst(hRegex, s, sResult, STRING_COMPLETE);
    Print(sResult);

    while StrRegexFindNext(hRegex, sResult, STRING_COMPLETE) do
      Print(sResult);
    end;
  end;
  StrRegexClose(hRegex);
end TMain;