TEXT
regexmatch
PATTERN
The regexmatch operator checks to see if the text on the left matches the regular expression on the right (see Regular Expressions).
Parameters
This operator has two parameters:
text – The text you want to match.
pattern – The regular expression.
Description
This operator checks to see if the text on the left matches the regular expression on the right (see Regular Expressions). The regexmatch operator is case insensitive (ignores the difference between upper and lower case) – if you want a case sensitive match use the regexmatchexact operator.
Entire books have been written about regular expressions (see Regular Expressions for recommendations), and you’ll probably want to read one or more of these books to get the maximum benefit from this powerful tool. Here are some very simple examples.
Does text contain a number?
"Deadline is in 34 days" regexmatch "[0-9]+" ☞ TRUE
"Deadline is Friday" regexmatch "[0-9]+" ☞ FALSE
Does text contain letters (and only letters and spaces) inside parentheses?
"Bob Smith" regexmatch "\([A-z ]+\)" ☞ FALSE
"Mary Wilson (Vice President)" regexmatch "\([A-z ]+\)" ☞ TRUE
Is the text a valid e-mail address (valid format, at least)?
"joe@bob.com" regexmatch "^[\w!#$%&'*+/=?`{|}~^.-]+@[A-Z0-9.-]+$" ☞ TRUE
"j oe@bob.com" regexmatch "^[\w!#$%&'*+/=?`{|}~^.-]+@[A-Z0-9.-]+$" ☞ FALSE
The final example gives you a taste of what Regular Expressions are capable of.
Error Messages
RegexMatch operands cannot be numeric. – You’ll see this message if either of the operands contains a numeric value.
See Also
- like -- checks to see if the text on the left matches the wildcard pattern specified on the right.
- match -- checks to see if the text on the left matches the wildcard pattern specified on the right.
- matchexact -- checks to see if the text on the left matches the wildcard pattern specified on the right.
- notmatch -- checks to see if the text on the left does not match the wildcard pattern specified on the right.
- notmatchexact -- checks to see if the text on the left doesn't match the wildcard pattern specified on the right.
- regexarray( -- applies a regular expression to a text value, then builds an array containing all of the substrings that match the regular expression (see Regular Expressions).
- regexarrayexact( -- applies a regular expression to a text value, then builds an array containing all of the substrings that match the regular expression (see Regular Expressions).
- regexliteral( -- adds \ characters to text as necessary so that it can be used as a literal in a regular expression.
- regexmatchexact -- checks to see if the text on the left matches the regular expression on the right (see Regular Expressions).
- regexreplace( -- replaces text with new text. The text to be replaced is determined by a regular expression.
- regexreplaceexact( -- replaces text with new text. The text to be replaced is determined by a regular expression.
- regexreplacefirst( -- replaces the first occurrence of a regular expression pattern with new text.
- regexreplacefirstexact( -- replaces the first occurrence of a regular expression pattern with new text.
- Regular Expressions -- Regular expressions can be used to look for a specified pattern in text and then specify what to do with each pattern match that is found
History
| 10.0 | New | Regular expression support is new in this version |