[]
The REGEXTEST function allows you to check whether any part of the supplied text matches a regular expression ("regex"). It returns TRUE if it does, and FALSE if it doesn't.
=REGEXTEST(text, pattern, [case_sensitivity])
Argument | Description |
---|---|
text (required) | The text or the reference to a cell containing the text you want to match against. |
pattern (required) | The regular expression ("regex") that describes the pattern of text you want to match. |
case_sensitivity | Determines whether the match is case-sensitive. 0: (default) Case sensitive 1: Case insensitive |
Return: TRUE
or FALSE
. The regex test result.
=REGEXTEST("abc","a") // TRUE
=REGEXTEST("abc","[A-Z]") // FALSE
=REGEXTEST("abc","[A-Z]", 1) // TRUE
=REGEXTEST("abc","[0-9]") // FALSE
The REGEXTEST function is compatible with Excel's REGEXTEST. At the same time, the previous version of the SJS.REGEXMATCH function has been deprecated, while maintaining backward compatibility. A list of differences between the two functions is as follows:
REGEXTEST Function | SJS.REGEXMATCH Function | |
---|---|---|
argument types | Only supports 0 or 1 to specify if the match is case-sensitive.
| Uses the string modifier.
|
match in multiline | Only regex matching can be used
| Can work with the modifier “m”
|
process non-string arguments | Accepts all types.
| Returns the #VALUE! for the non-string input. |