Text
REGEXTEST Function in Excel
Returns TRUE if text matches a regular expression pattern, otherwise FALSE.
Syntax
- =REGEXTEST(text, pattern, [case_insensitive])
Arguments
- text (required): Text to test against the pattern
- pattern (required): Regular expression pattern in double quotes
- case_insensitive (optional): TRUE to ignore case (default FALSE)
Examples
- =REGEXTEST("[email protected]", "^[\\w.-]+@[\\w.-]+\\.\\w+$") - Test email-like format - Result: TRUE
- =REGEXTEST(A2, "^\\d{5}$") - Five-digit ZIP pattern - Result: TRUE or FALSE
- =IF(REGEXTEST(A2,"@"), "Has @", "Missing @") - Simple validation label - Result: Has @
Excel REGEXTEST function documentation
- REGEXTEST checks whether text matches a regular expression pattern and returns TRUE or FALSE — ideal for validation columns in imported data.
- Syntax: =REGEXTEST(text, pattern, [case_insensitive]). Requires Microsoft 365 or Excel 2021+ with regex functions.
- Use for email-like checks, SKU patterns, postal codes, and flagging rows before [FILTER](/functions/filter/) or Power Query cleanup.
- Deep guide: [REGEXTEST tutorial](/blog/excel-regextest-function-guide-and-examples/) with email and ID examples.
REGEXTEST syntax and pattern tips
- text (required): cell or string to test.
- pattern (required): regex in double quotes — ^ anchors start, $ anchors end, \d digits, \w word chars.
- case_insensitive (optional): TRUE ignores case; default FALSE.
- Example: =REGEXTEST(A2, "^[\\w.-]+@[\\w.-]+\\.[A-Za-z]{2,}$") for basic email-shaped text.
REGEXTEST with FILTER and IF
- Validation label: =IF(REGEXTEST(A2,"^\\d{5}$"), "OK", "Fix ZIP") for five-digit US ZIP pattern.
- Filter valid rows: =FILTER(Data, REGEXTEST(Data[Email], "@")) as a quick sanity check before mail merge.
- Combine patterns: test twice with OR logic using + (TRUE=1): =REGEXTEST(A2,"@")+REGEXTEST(A2,"\\.")>0 is crude; prefer one precise pattern.
- When regex fails, fall back to [FIND](/functions/find/) / [SEARCH](/functions/search/) for simple substring rules in older Excel.
Common REGEXTEST errors
- #NAME? — Excel build lacks REGEXTEST (Excel 2019 or older desktop).
- #VALUE! — invalid regex syntax; test patterns in the blog guide or a regex tester first.
- Unexpected FALSE — pattern too strict; loosen anchors or allow optional groups with ?.
- Performance — avoid REGEXTEST on full-column references in huge sheets; use structured Table ranges.
People also ask
- Is REGEXTEST in Excel 2019? — No. Use Microsoft 365 or Excel 2021+.
- REGEXTEST vs EXACT? — EXACT compares full strings; REGEXTEST matches flexible patterns.
- Does REGEXTEST work on numbers? — Coerce with TEXT or store IDs as text for leading zeros.
Common errors
- #NAME? in Excel versions without regex functions
- #VALUE! for invalid regex syntax
Use cases
- Data validation
- Import auditing
- Format flags
- Email and ID checks
Frequently asked questions
- Which Excel versions support REGEXTEST? Microsoft 365 and Excel 2021+ builds that include regex functions. Excel 2019 and older return #NAME?.
- How is REGEXTEST different from EXACT? EXACT compares two full strings for equality. REGEXTEST checks whether text matches a flexible pattern such as digits, emails, or codes.
- Can REGEXTEST ignore case? Yes. Set the third argument to TRUE: =REGEXTEST(A1, "abc", TRUE) matches ABC, Abc, and abc.
Editorial review
- Reviewed by Excel.Directory Editorial Team. Updated May 2026.
When to use REGEXTEST
- Data validation — common Text scenario for REGEXTEST.
- Import auditing — common Text scenario for REGEXTEST.
- Format flags — common Text scenario for REGEXTEST.
- Email and ID checks — common Text scenario for REGEXTEST.
REGEXTEST in the Text category
- Browse all Text functions at /categories/text/ for related formulas.
- REGEXTEST syntax: =REGEXTEST(text, pattern, [case_insensitive])
- text (required): Text to test against the pattern
- pattern (required): Regular expression pattern in double quotes
- case_insensitive (optional): TRUE to ignore case (default FALSE)
- Confirm REGEXTEST arguments match the syntax shown above before filling down.
- Lock table and range references with $ when copying formulas across rows or sheets.
Formula checklist before you copy down
- Confirm REGEXTEST arguments match the syntax shown above before filling down.
- Lock table and range references with $ when copying formulas across rows or sheets.
- If results look wrong, check for text stored as numbers and invisible spaces with TRIM.
- Spot-check three known input rows manually against expected output.
Related Excel functions
- REGEXEXTRACT (/functions/regexextract/): Extracts text that matches a regular expression pattern, optionally from a capture group.
- REGEXREPLACE (/functions/regexreplace/): Replaces text that matches a regular expression pattern with replacement text.
- FIND (/functions/find/): Finds one text string within another and returns the starting position (case-sensitive).
- SEARCH (/functions/search/): Finds one text string within another and returns the starting position (case-insensitive, supports wildcards).
- IF (/functions/if/): Returns one value if a condition is TRUE and another value if it's FALSE.
Errors to watch for
- #NAME? in Excel versions without regex functions — review causes on linked error pages in the directory.
- #VALUE! for invalid regex syntax — review causes on linked error pages in the directory.
Copy-paste audit workflow
- Enter REGEXTEST on three test rows with known expected output documented on a QA tab.
- Fill down only after absolute references are locked on lookup tables and rate tables.
- Compare against manual calculation or a calculator for financial and statistical functions.
- Search this directory for comparison guides when choosing between similar functions in the same category.
REGEXTEST worked examples to copy
- =REGEXTEST("[email protected]", "^[\\w.-]+@[\\w.-]+\\.\\w+$") — Test email-like format. Expected result: TRUE.
- =REGEXTEST(A2, "^\\d{5}$") — Five-digit ZIP pattern. Expected result: TRUE or FALSE.
- =IF(REGEXTEST(A2,"@"), "Has @", "Missing @") — Simple validation label. Expected result: Has @.
REGEXTEST reference summary for crawlers and offline review
- REGEXTEST belongs to the Text category in Excel. Returns TRUE if text matches a regular expression pattern, otherwise FALSE.
- Full syntax: =REGEXTEST(text, pattern, [case_insensitive]). Open /functions/regextest/ for parameters, FAQs, and related pages.
- Common mistakes: #NAME? in Excel versions without regex functions; #VALUE! for invalid regex syntax
- Pair this function with comparison guides when another Excel formula might fit the same task better.
- Review fix-excel-formula-errors when unexpected errors appear after upgrading Excel or sharing across locales.