REGEXMATCH function
Text
The text string the regular expression is applied to.
Regex
The JavaScript regular expression used to find text.
CaseInsensitive
Whether the regular expression should ignore case. If omitted, FALSE is assumed.
MultipleLines
Whether the regular expression anchors ^
and
$
should be relative to a line of text or to the text
string in its entirety. If omitted, FALSE is assumed.
Returns
Whether a given text string matches a JavaScript regular expression.
Returns whether a given text string matches a JavaScript regular expression. REGEXMATCH("Test123", "\w+\d\d\d")REGEXMATCH("Test123"; "\w+\d\d\d") returns TRUE, because "Test" matches the regular expression, meaning that it consists of one or more letters—"\w+"—followed by three digits (numbers)—"\d\d\d"—as specified by the regular expression "\w+\d\d\d".
Regular expressions are a powerful tool to search through and manipulate text, though they take time to master. For an introduction, refer to the blog post we wrote when Calcapp gained support for regular expressions.
Counting array elements
Use REGEXMATCH in conjunction with COUNTIF to determine the number of array elements which match a certain regular expression:
This formula returns 1, because only "123" matches the "\d\d\d" regular expression (which only accepts exactly three digits).
Examples
Returns TRUE, as "Test" matches the regular expression "\w+\d\d\d". Indeed, "Test123" consists of one or more letters, "\w+", followed by three digits (numbers), "\d\d\d".
Returns whether the value of TextField1 matches a US Social Security number.
Returns whether the value of TextField1 matches an email address. This regular expression is simpler and less complete than the one used internally by the ISEMAIL function.
Returns TRUE, because "\d" in the regular expression matches the sole number in "test0test", ignoring the two "test" strings.
Returns FALSE, because "\d" in the regular expression needs to match "test0test" in its entirety, because of the two anchors "^" and "$". The match fails because of the two "test" strings. For many more examples involving REGEXMATCH and other similar functions, refer to a blog post written at the time Calcapp's regular expression support was introduced.