Excel functions / Text
REGEXTEST function
TRUE if any part of the text matches a regular expression.
Syntax
=REGEXTEST(text, pattern, [case_sensitivity])
Arguments
text: The text to test.pattern: The regular expression, such as "[0-9]+" for a run of digits.case_sensitivity(optional): 0 (default): match case. 1: ignore case.
When to use it
REGEXTEST is TRUE when a text matches a regular expression: a pattern that describes text, such as "five digits", "an email address" or "starts with INV-". It validates data that a simple comparison cannot.
Examples
Is it a five-digit postcode?
A B C 1 Postcode 2 90210 TRUE In C2:
=REGEXTEST(A2, "^\d{5}quot;)→ TRUEDoes it look like an email address?
A B C 1 Email 2 ana.example.com FALSE In C2:
=REGEXTEST(A2, "^[^@\s]+@[^@\s]+\.[a-z]+quot;)→ FALSE
Common mistakes
- Matching part of the text. Without ^ and $, a pattern matches anywhere: "\d{5}" is TRUE for "abc12345xyz".
- Older versions of Excel. REGEXTEST is in Excel for Microsoft 365 only.
Try REGEXTEST in the playground
Practise it
Related functions
- REGEXEXTRACT: The part of the text that matches a regular expression: the first match, all of them, or its groups.
- REGEXREPLACE: Replaces the parts of the text that match a regular expression.
- ISNUMBER: TRUE if the value is a number (dates count too).
- SEARCH: Position of one text inside another (not case-sensitive, allows wildcards).