The function searches for the first substring that matches the specified regular expression and returns the index where the substring starts.
Declaration
INT %RxFind(
TEXT in Text,
TEXT in regExp,
INT in from := 0,
INT out endIndex := 0
)
Parameters
text
Text, which is to be searched.
regExp
Regular expression that will be searched in the input parameter text.
from
Index, from where the input parameter text will be searched (optional input parameter).
endIndex
Index in text, where the substring matching the specified regular expression ends (optional output parameter).
Example
The function returns the index, where the substring matching the specified regular expression starts. Optional parameters is endIndex. If this parameter is entered, after the function call there is stored ending index of the substring that matches the specified regular expression.
If the searching is unsuccessfull, or if the from parameter exceeds the total length of input text, the function returns 0.
If the parameter regExp is not valid regular expression, the function returns -1.
If some of the input parameters is invalid, the function returns undefined value.
%RxFind("text some text", "[a-z]+") ;returns the value of 1
%RxFind("text some text", "[a-z]+", 1) ;returns the value of 1
%RxFind("123text some text", "[a-z]+", 1) ;returns the value of 4
%RxFind("text some text", "[a-z]+", 5 _last) ;returns the value of 6, _last = 11
%RxFind("text some text", "[a-z]+", 20, _last) ;returns the value of -1, _last = -1
%RxFind("text some text", "", 20, _last) ;returns undefined value (length of regexp is 0), _last = 0