matches()
Table of Contents
Overview
The matches() function takes string and regexString (regular expression) as arguments. It compares both the strings and returns True if both are found to be equal. Otherwise, it returns False.
Note: This function performs a case-sensitive comparison.
Return Type
- Boolean
Syntax
<variable> = <string>.matches(<regexString>);
(OR)
<variable> = matches( <string>, <regexString> );
| Parameter | Description | Data type |
|---|---|---|
| <variable> | Variable which will contain the boolean value, true or false. | BOOLEAN |
| <string> | The string to be compared with the regular expression | TEXT |
| <regexString> | The regular expression to be compared with the string. | TEXT |
Examples
The following examples show how the matches() text function checks if a string fits a given regular expression pattern:
//Checks if IDValue has 2 uppercase letters, 6 digits, and 1 uppercase letter
IDValue="ID004500F"; retValue=matches(IDValue,"[A-Z]{2}[0-9]{6}[A-Z]"); //returns true
//Checks if num matches a dollar amount with exactly 2 decimal places num="$345.78"; ret=matches(num,"\$[0-9]+\.[0-9]{2}");//returns true
//Checks if useremail matches a basic lowercase email format
useremail="jane2023@zylker.com"; format_check=matches(useremail,"[a-z 0-9]+\@[a-z]+\.[a-z]+");//returns true