isMatch()

The strLib.isMatch()system function checks if the string matches a given regular expression. It returns “true” if the string matches the entire regular expression, “false” otherwise.

Syntax

   strLib.isMatch(
             target STRING | CHAR | DBCHAR | MBCHAR | UNICODE In, 
              regex STRING | CHAR | DBCHAR | MBCHAR | UNICODE In)
  returns (result BOOLEAN)
target

Input can be any value that is assignment compatible with any of the above types.

regex

Input can be any value that is assignment compatible with any of the above types.

result

It returns “true” if the regexmatches the targetstring, “false” otherwise.

Example

  function main()
          myStr String = “Customer”; 
          regexStr String = “(.*)sto(.*)”; 
          myChar Char(8) = “Customer”; 
          regexChar Char(11) = “(.*)sto(.*)”;

          sysLib.writeStdout(“Does ‘myString’ match the regex? “+ strLib.isMatch(myStr, regexStr)); 
          sysLib.writeStdout(“Does ‘myChar’ match the regex? “+ strLib.isMatch(myChar, regexChar));
  end

The output is as follows:

   Does myString match the regex? true 
   Does myChar match the regex? true