Practice free

REGEXTEST function

REGEXTEST checks whether text fits a pattern and returns TRUE or FALSE. It is handy for validating IDs, emails or postal codes inside IF or FILTER, and it matches anywhere in the text unless you anchor the pattern.

Example

Read it as a sentence: check whether the text abc123 contains a digit, which gives TRUE.

Practice this in the app

Syntax

REGEXTEST(text, pattern, [case_sensitivity])

Arguments in [square brackets] are optional.

text (required)
The text to check.
pattern (required)
The regular expression.
case_sensitivity (optional)
0 case-sensitive (default), 1 ignore case.

Returns: TRUE if the text matches the pattern, otherwise FALSE.

What Excel actually returns

Each formula below was run in desktop Excel. The result is exactly what the cell showed, errors included.

FormulaExcel showsCase
=REGEXTEST("abc","^a") TRUE Match
=REGEXTEST("abc","^b") FALSE No match
=REGEXTEST("ABC","abc") FALSE Case-sensitive default
=REGEXTEST("ABC","abc",1) TRUE Case-insensitive
=REGEXTEST(123,"^\d+$") TRUE Number input
=REGEXTEST({"a1","b"},"\d") TRUE Array spills
=REGEXTEST("abc","[") #VALUE! Invalid pattern
=REGEXTEST("abc","b",2) #VALUE! Bad case_sensitivity

Watch out for

  • Matches anywhere in the text unless you anchor with ^ and $.

Where it works

Excel
REGEXTEST is only in Excel for Microsoft 365 and Excel for the web. Recent Microsoft 365 builds only.
Google Sheets
Done with a different function: `REGEXMATCH`. REGEXMATCH(text, regular_expression) is the Sheets equivalent.

Part of Text functions. Every result on this page was measured in desktop Excel, build 16.0.20527. Last updated .