What REGEXTEST does
REGEXTEST checks text against a pattern and returns a logical TRUE or FALSE. Use it to flag product codes with the wrong format or to find a matching fragment in a description. It leaves the original text intact.
A match anywhere in the text is enough unless your pattern requires the whole value to match. Microsoft's REGEXTEST reference documents PCRE2 as its regular expression syntax.
Practical examples
Find a code inside a description
Put X AB-0012 old in A6:
=REGEXTEST(A6,"[A-Z]{2}-[0-9]{4}")FormulaThe result is TRUE. The pattern finds two uppercase ASCII letters, a hyphen, and four digits in AB-0012. It doesn't reject the surrounding words.
Require the entire value to be a code
Keep A6 as X AB-0012 old and put AB-0012 in A5. Test A6 with:
=REGEXTEST(A6,"\A[A-Z]{2}-[0-9]{4}\z")FormulaThe result is FALSE. Changing A6 to A5 in this formula returns TRUE. The \A and \z markers require the match to begin and end with the entire text, so extra words or spaces fail the check.
Allow lowercase only when the rule permits it
Put ab-0012 in A7:
=REGEXTEST(A7,"\A[A-Z]{2}-[0-9]{4}\z",1)FormulaThe result is TRUE because the final argument turns off case sensitivity. Omitting it, or using 0, returns FALSE for the same lowercase code. This setting changes the comparison; it doesn't uppercase A7.
Common mistakes and notes
A partial match is different from validation
Use whole-text markers when every character must follow the rule. In PCRE2, \z is the absolute end of the text; $ can also match before a final newline. The PCRE2 assertion documentation explains the distinction. Use a single backslash before A and lowercase z in the Excel formula.
With AB-0012 in A5, =REGEXTEST(A5&CHAR(10),"\A[A-Z]{2}-[0-9]{4}\z") returned FALSE in Excel for Mac 16.114 (build 16.114.26101123) on November 11, 2026. Changing the pattern to ^[A-Z]{2}-[0-9]{4}$ returned TRUE for the same final line break. The absolute end marker keeps that unwanted character from passing the check.
A matching format doesn't prove the code exists
ZZ-9999 passes this pattern whether or not it appears in your catalog. Use a separate lookup to check membership. For a case-sensitive comparison against one exact value, see EXACT.
TRUE and FALSE are logical values
You can pass the result to IF to display a review label. To return the matching code itself, use REGEXEXTRACT. Microsoft currently lists REGEXTEST for Excel for Microsoft 365 and Excel for Microsoft 365 for Mac.