REGEXTEST Function in Microsoft Excel: Validate Text Patterns
Check product codes with Excel REGEXTEST, distinguish partial from whole-text matches, and control case sensitivity with worked examples.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: REGEXTEST returns a Boolean answer to a pattern-matching question. For example, =REGEXTEST("AB-104","^[A-Z]{2}-[0-9]{3}$") returns TRUE: the entire value has two uppercase letters, a hyphen and three digits.
Availability and version history
- First introduced: Microsoft announced these regex functions as an Insider preview on May 20, 2024. The published preview minima were Windows Version 2406 (Build 17715.20000) and Mac Version 16.86 (Build 24051422). These are the announcement’s availability thresholds, not proof of the earliest internal implementation. Microsoft introduction
- Current status: documented for Microsoft 365 Windows and Mac; Microsoft announced a wider platform rollout in November 2024. Perpetual-edition availability is not established by that rollout. Release update
- Last supported version: no retirement endpoint established. Verify availability in the installed Microsoft 365 build.
- Evidence checked: October 14, 2026. Current function help. Examples were independently checked, not executed in Excel.
Syntax and defaults
=REGEXTEST(text, pattern, [case_sensitivity])
text: a text value or reference containing the value to inspectpattern: a regular expression written as quoted text or held in another cellcase_sensitivity: omit it, or use0, for case-sensitive matching; use1to ignore case
Microsoft documents PCRE2 as the regular-expression engine. A successful match can be anywhere in the input. Use anchors when the rule must cover the complete value. Official REGEXTEST reference
The formulas use English function names and comma argument separators. Locale settings may require semicolons between arguments. Punctuation inside a quoted regex belongs to the pattern.
Prepare a small test sheet
Enter the specified text in A1:A6 using the cell addresses below. The interpretation column is explanatory and is not part of the worksheet input.
| Cell in column A | Enter this text | Interpretation |
|---|---|---|
| A1 | Code | Heading |
| A2 | AB-104 | Correct format |
| A3 | ab-104 | Lowercase letters |
| A4 | Note AB-104 | Extra prefix |
| A5 | AB-104X | Extra suffix |
| A6 | AB-10 | Too few digits |
Use column D for results so the formulas do not overwrite the input.
Example 1: validate the complete code
In D2 enter:
=REGEXTEST(A2,"^[A-Z]{2}-[0-9]{3}$")
Fill down through D6. The expected results are:
| Formula cell | Expected Boolean |
|---|---|
| D2 | TRUE |
| D3 | FALSE |
| D4 | FALSE |
| D5 | FALSE |
| D6 | FALSE |
^ fixes the beginning, [A-Z]{2} requires two uppercase letters, and [0-9]{3} requires three digits. $ anchors the ending for these single-line inputs. The prefix in A4 and suffix in A5 therefore fail. This rule checks structure only: it does not prove a code exists in a product catalogue.
Example 2: permit lowercase input deliberately
=REGEXTEST(A3,"^[A-Z]{2}-[0-9]{3}$",1)
Expected result: TRUE. The third argument changes case handling without changing the required length, hyphen or digit count. The same formula using 0 returns FALSE for A3.
If lowercase codes should be rejected, keep the default. Do not quietly turn on case-insensitive matching to hide inconsistent source data.
Example 3: understand partial matching
=REGEXTEST(A4,"[A-Z]{2}-[0-9]{3}")
Expected result: TRUE, because A4 contains AB-104 even though its complete text is Note AB-104. This is appropriate for finding a code inside a note, but unsuitable for enforcing the whole-cell format from example 1.
Advanced example: return an actionable label
=IF(A2="","Missing",IF(REGEXTEST(A2,"^[A-Z]{2}-[0-9]{3}$"),"Ready","Review"))
For the five supplied codes the labels are Ready, Review, Review, Review, Review. If A2 is cleared, its result becomes Missing. The initial blank check separates absent input from a malformed code, which is useful when reviewing imports.
Keep the raw code alongside the label. A validation formula should not erase the evidence needed to resolve an import problem.
Troubleshooting and boundary cases
- Unexpected
TRUE: check whether the pattern is unanchored, or whether*permits an empty match. For at least one digit,[0-9]+is clearer than[0-9]*. - Unexpected
FALSE: inspect spaces, nonbreaking spaces, line breaks and look-alike punctuation. A typographic dash does not equal the ordinary-used above. - Formula or pattern error: first try the literal example in the quick answer, then restore your pattern a piece at a time. Balance parentheses and brackets. An invalid regex is not the same as a valid pattern with no match.
#NAME?: check spelling and feature availability. Changing the data cannot add a function missing from the installed build.- Avoid treating a simple regex as a complete email-address, postal-address or identity validator. Format checks do not establish deliverability, validity or identity.
Moving the formula to Google Sheets
Google Sheets has REGEXMATCH. Its regex dialect and function signature differ. The simple ASCII pattern above is deliberately conservative, but a working PCRE2 expression is not a general compatibility guarantee.
Related guides
Verification: Official reference reviewed October 14, 2026. All data in this tutorial is fictional. Boolean outputs were independently checked; no native Excel execution or screenshot is claimed.