# REGEXTEST function in Excel

> REGEXTEST checks whether text contains a match for a regular expression and returns TRUE or FALSE.

Source: https://spreadsheetpractice.com/functions/regextest · Updated October 28, 2026 · Formulas and results on this page were run by the Spreadsheet Practice formula engine on October 30, 2026

## Quick answer

- **What it does:** REGEXTEST checks whether text contains a match for a regular expression and returns TRUE or FALSE.
- **Syntax:** `=REGEXTEST(text, pattern, [case_sensitivity])`
- **Most common use:** `=REGEXTEST(A2,"^[A-Z]{2}\d{4}$")` returns TRUE (Two capital letters, then four digits: TRUE)
- **Available in:** Microsoft 365 only
- **Category:** [Text functions](https://spreadsheetpractice.com/functions/category/text)
- **Returns:** TRUE or FALSE.
- **Google Sheets:** Google Sheets has REGEXMATCH instead, without the case_sensitivity argument.

## What it does

REGEXTEST checks whether text contains a match for a regular expression and returns TRUE or FALSE. Use it to validate formats such as order IDs, emails or postcodes, or as a condition inside FILTER and counting formulas. Matching is case-sensitive unless you set case_sensitivity to 1.

## Syntax

`=REGEXTEST(text, pattern, [case_sensitivity])`

| Argument | Required? | What it is |
|---|---|---|
| `text` | Required | The text to test. |
| `pattern` | Required | The regular expression, in quotes, such as "^[A-Z]{2}\d{4}$". |
| `case_sensitivity` | Optional | Optional: 0 (default) for case-sensitive, 1 to ignore case. |

## Examples

Each result was calculated by running the formula on the sample sheet.

| Cell | Formula | Result | What it shows |
|---|---|---|---|
| B2 | `=REGEXTEST(A2,"^[A-Z]{2}\d{4}$")` | TRUE | Two capital letters, then four digits: TRUE |
| B3 | `=REGEXTEST(A3,"^[A-Z]{2}\d{4}$")` | FALSE | Lowercase letters fail a case-sensitive test |
| B4 | `=REGEXTEST(A3,"^[A-Z]{2}\d{4}$",1)` | TRUE | The same ID passes when case is ignored |

### The sample sheet

Every formula above runs on this data:

|  | A | B |
|---|---|---|
| 1 | Order ID | Result |
| 2 | AB1234 | TRUE |
| 3 | ab1234 | FALSE |
| 4 | AB12X4 | TRUE |

## Common mistakes

| What you see | Why, and how to fix it |
|---|---|
| Always FALSE | The pattern is case-sensitive by default. Add 1 as the third argument, or use [A-Za-z]. |
| Matches more than you meant | Without ^ and $, the pattern can match anywhere inside the text: "\d{4}" is TRUE for "AB12345". |
| #NAME? | REGEXTEST is in Microsoft 365 only. Older versions show #NAME?; Google Sheets uses REGEXMATCH. |

## Tips

- Count matching rows with =SUM(--REGEXTEST(A2:A100,"pattern")).

## Related functions

- [REGEXEXTRACT](https://spreadsheetpractice.com/functions/regexextract): REGEXEXTRACT pulls out the part of a text that matches a regular expression: an order number, an email domain, the digits in a messy code.
- [ISNUMBER](https://spreadsheetpractice.com/functions/isnumber): ISNUMBER returns TRUE when a value is a real number, which includes dates and times.
- [SEARCH](https://spreadsheetpractice.com/functions/search): SEARCH returns the position of one piece of text inside another, ignoring upper and lower case, and it understands the ? and * wildcards.

## Questions

### How do I check if a cell matches a pattern in Excel?

=REGEXTEST(A2,"pattern") returns TRUE or FALSE. For example "^\d{5}$" checks for exactly five digits.

### Is REGEXTEST case-sensitive?

Yes, by default. Set the third argument to 1 to ignore case.

## Practice

A graded REGEXTEST exercise ("Valid ticket IDs") is on [the REGEXTEST page](https://spreadsheetpractice.com/functions/regextest). It is checked instantly, then re-checked on changed data.

---

Spreadsheet Practice (https://spreadsheetpractice.com) teaches spreadsheet formulas by practice: every exercise is graded in a live grid and re-checked on changed data.
