REGEXTEST function

Category: Text
Introduced: Excel 365

Summary

Determines whether any part of text matches the pattern

Syntax

The REGEXTEST function determines whether any part of text matches the pattern. The syntax of the REGEXTEST function is:
REGEXTEST(text, pattern, [case_sensitivity])
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. By default, the match is case-sensitive. Enter one of the following: 0: Case sensitive 1: Case insensitive
Notes: When writing regex patterns, symbols called ‘tokens’ can be used that match with a variety of characters. These are some simple tokens for reference:
“[0-9]”: any numerical digit
“[a-z]”: a character in the range of a to z
“.”: any character
“a”: the “a” character
“a*”: zero or more “a”
“a+”: one or more “a”
All regular expressions for this function, as well as REGEXEXTRACT and REGEXREPLACE use the PCRE2 'flavor' of regex.
REGEXEXTRACT always return text values. You can convert these results back to a number with the VALUE function.

Example

=REGEXTEST(A2,"a")
=REGEXTEST(A2,"[a-z]")
=REGEXTEST(A2,"[A-Z]")
=REGEXTEST(A2,"[aeiou]")
=REGEXTEST(A2,"[0-9]")
=REGEXTEST(A2,"^\([0-9]{3}\) [0-9]{3}-[0-9]{4}$")

Microsoft Support Page

https://support.microsoft.com/en-us/office/regextest-function-7d38200b-5e5c-4196-b4e6-9bff73afbd31

Back to Functions