REGEXTEST Function

Excel 365, Excel 2021

Summary

The REGEXTEST function performs regular expression matching to determine if any part of a text string matches a specified pattern. It returns TRUE for matches and FALSE otherwise, enabling powerful text pattern validation and data analysis.

Syntax

REGEXTEST(text, pattern, [case_sensitivity])

Parameters

Parameter Type Required Description
text Text Yes The text or cell reference containing text to match against
pattern Text Yes Regular expression pattern to test for matches
case_sensitivity Number No Optional: 0=case-sensitive (default), 1=case-insensitive

Using the REGEXTEST Function

REGEXTEST revolutionizes text analysis in Excel by bringing powerful regex capabilities to spreadsheet users. Use it to validate formats, search for patterns, or filter data based on complex string matching rules far beyond basic wildcard searches.

Common REGEXTEST Examples

Basic Character Matching

=REGEXTEST(A1,"a")

Returns TRUE if cell A1 contains letter 'a' anywhere (e.g., 'alfalfa')

Lowercase Letter Detection

=REGEXTEST("alfalfa","[a-z]")

TRUE - detects any lowercase letters in the text

US Phone Number Validation

=REGEXTEST(A1,"^\([0-9]{3}\) [0-9]{3}-[0-9]{4}$")

TRUE for '(378) 555-4195', FALSE for '+1(878) 555-8622'

Case-Insensitive Email Check

=REGEXTEST(B1,"[a-z]+@[a-z]+\.[a-z]+",1)

TRUE for '[email protected]' using case-insensitive mode

Frequently Asked Questions

Uses PCRE2 regex flavor, supporting advanced patterns and features.

Set case_sensitivity to 1. Default (0 or omitted) is case-sensitive.

Yes, returns TRUE if pattern matches anywhere in the text.

Common Errors and Solutions

#VALUE! error

Cause: Invalid regex pattern syntax

Solution: Verify pattern uses valid PCRE2 regex syntax

Unexpected FALSE results

Cause: Case sensitivity mismatch or unescaped special characters

Solution: Use case_sensitivity=1 or escape parentheses with \\

Notes

  • Escape special characters like ( ) with backslash \\
  • [0-9] matches digits, [a-z] matches lowercase letters
  • Works with REGEXEXTRACT and REGEXREPLACE functions
  • Pattern '^...$' matches entire string only

Compatibility

Available in: Excel 365, Excel 2021

Not available in: Excel 2019, Excel 2016, Excel 2013, Excel 2010, Excel 2007

Content last reviewed: December 9, 2025
Update frequency: As needed
Excel versions tested: Excel 365, Excel 2021