Does the text match a pattern — yes or no? REGEXTEST returns TRUE/FALSE, ideal for validating formats like emails, postal codes, or IDs in a single formula or a data-validation rule.
^ and $ anchors require the entire cell to fit the shape.
The example
Flagging which entries match an email shape.
| A | B | |
|---|---|---|
| 1 | Entry | Valid? |
| 2 | ann@dfwexcel.com | TRUE |
| 3 | not-an-email | FALSE |
The formula
Pattern test, TRUE or FALSE:
How it works
REGEXTEST answers “does it match?”:
- Give it the text and a pattern; it returns TRUE if the pattern is found.
- Anchor with
^(start) and$(end) to require the whole cell to match a format, not just contain it. - Combine with IF for a label:
=IF(REGEXTEST(A2, pattern), "OK", "Check"). - Drop it into Data Validation → Custom to block entries that don’t match a required format.
Validate on entry: a Data Validation custom rule =REGEXTEST(A1, "^[A-Z]{2}-[0-9]{4}$") enforces a code format like “AB-1234” as people type. Far cleaner than chaining LEN/ISNUMBER/MID checks.
Try it: interactive demo
Test text against a pattern.
Variations
Label OK / Check
Readable flag:
Data Validation rule
Custom validation:
Contains a digit?
Simple test:
Pitfalls & errors
Anchor for whole-cell match. Without ^…$, REGEXTEST is TRUE if the pattern appears anywhere — “contains” not “equals.”
365 (2024+) only. Older Excel returns #NAME?.
Shape, not truth. A valid format isn’t a guarantee — a well-formed email can still be undeliverable.
Practice workbook
Frequently asked questions
How do I check if text matches a pattern in Excel?
How do I validate a code format as it's typed?
Why is REGEXTEST TRUE for partial text?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class