Appearance
RegExMatch
The function RegExMatch looks for a match to the pattern specified by ARegExpr in the string AInputStr.
Where the pattern matches, a boolean True value will be returned indicating that a match was found. False will be returned where no match was found.
Declaration: Function RegExMatch(const ARegExpr, AInputStr : string) : boolean;
Several examples follow.
pascal
procedure ScriptEvent(var Value:Variant);
var
Str1, Str2 : string;
begin
Str1 := 'a';
Str2 := 'banana';
//Returns true, i.e. the pattern has been matched
If RegExMatch(Str1,Str2) then
LogInfo('Yes, we have a match!')
else
LogInfo('No match today . . . ');
If RegExMatch('a','banana') then
LogInfo('Yes, we have a match!')
else
LogInfo('No match today . . . ');
//Returns false – "7" not matched within "banana"
Str1 := '7';
If RegExMatch(Str1,Str2) then
LogInfo('Yes, we have a match!')
else
LogInfo('No match today . . . ');
end;Some other examples -
- RegExMatch('abc','abc') //Returns True (whole string matches exactly)
- RegExMatch('abc','000abc???') //Returns True (matches as sub-string)
- RegExMatch('abc','cab') //Returns False (sequence abc not found in cab)
- RegExMatch('[abc]','cab') //Returns True (at least one character is a, b, or c)
- RegExMatch('[abc]','a') //Returns True (at least one character is a, b, or c)
- RegExMatch('[a-c]','b') //Returns True (at least one character is a, b, or c)
- RegExMatch('[a-c]','symbol') //Returns True (at least one of a, b, or c)
- RegExMatch('[a-c]','symbol') //Returns True (at least one of a, b, or c)
- RegExMatch('[a-c]','never') //Returns False (no character is a, b, or c)
- RegExMatch('[^0-9]','2B') //Returns True (at least one non-digit)
- RegExMatch('[\-0-9]','part-time') //Returns True (hyphen is “escaped”)
- RegExMatch('\d','Route 66') //Returns true – the pattern “\d” matches a single digit.
- RegExMatch ('\d{3}','Route 66') //Pattern “\d{3}” matches 3 consecutive digits; function returns false.

