REGEXTEST Function in Excel 2007, 2010, 2013, 2016, 2019, 2021 & 2024

The REGEXTEST function is officially available only on Excel 365, but thanks to Modern Functions Update (MFU) you can now run it on your Excel 2007, 2010, 2013, 2016, 2019, 2021 and 2024 versions. It works exactly as its original Microsoft counterpart.


Description

The REGEXTEST function checks whether any part of the supplied text matches a regular expression (“regex”) pattern. It returns TRUE if a match is found, and FALSE if not.

Regular expressions are sequences of characters that define search patterns, commonly used for string searching and text parsing. They are incredibly versatile and are often used to check if a string contains a certain pattern.

This is particularly useful for:

  • Data validation: Verify that text follows a specific format (phone numbers, email addresses, postal codes, product IDs)
  • Quality control: Identify entries that contain disallowed characters or don’t meet required standards
  • Pattern detection: Check for the presence of specific patterns like digits, letters, or special characters
  • Clean data: Flag records that need correction based on pattern mismatches
  • Complex text analysis: Perform sophisticated checks that would be impossible with traditional Excel functions

Syntax

=REGEXTEST(text, pattern, [case_sensitivity])
ArgumentDescription
textRequired. The text value you want to evaluate.
patternRequired. The regular expression to test against.
[case_sensitivity]Optional. Determines if the match is case-sensitive. 0 (default) = case-sensitive, 1 = case-insensitive.
regextest-function-excel-2007-2010-2013-2016-2019-2021-2024
Regextest function in Excel 2007 thanks to MFU

Important Notes

  • The result of REGEXTEST is a logical value: TRUE if the text matches the regex pattern, FALSE if it does not.
  • All regular expressions for this function use the PCRE2 flavor of regex.
  • The function is case-sensitive by default. Use case_sensitivity = 1 to ignore case.
  • If the text contains multiple values (e.g., a range), REGEXTEST will return an array of results.

Basic Tokens Reference

TokenMatches
[0-9]Any numeric digit
[a-z]Any lowercase letter
[A-Z]Any uppercase letter
.Any single character
aThe literal character “a”
a*Zero or more “a”
a+One or more “a”
\dAny digit (same as [0-9])
\sAny whitespace character
^Start of a text string (anchor)
$End of a text string (anchor)
|OR logic between patterns

Examples

Basic Usage – Checking for Specific Text

To check if cell A2 contains the letter “a”:

=REGEXTEST(A2, "a")

Returns: TRUE if “a” is present, otherwise FALSE.

Checking for Lowercase Letters

To check if text contains any lowercase letters:

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

Returns: TRUE if any lowercase letters exist.

Checking for Uppercase Letters

=REGEXTEST(A2, "[A-Z]")

Returns: TRUE if any uppercase letters exist.

Checking for Vowels

=REGEXTEST(A2, "[aeiou]")

Returns: TRUE if any vowels are present.

Checking for Digits

=REGEXTEST(A2, "[0-9]")

Returns: TRUE if any digits are present.

Validating a Phone Number Format

To check if a phone number matches the format (###) ###-####:

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

Returns: TRUE for valid format, FALSE otherwise.

This pattern:

  • ^ matches the start of the text
  • \( matches an opening parenthesis (escaped with backslash)
  • [0-9]{3} matches exactly 3 digits (area code)
  • \) matches a closing parenthesis
  • [0-9]{3} matches the next 3 digits
  • - matches a hyphen
  • [0-9]{4} matches exactly 4 digits
  • $ matches the end of the text

Case-Insensitive Search

To search for “invoice” regardless of case (Invoice, INVOICE, etc.):

=REGEXTEST(A2, "invoice", 1)

Returns: TRUE if “invoice” is found in any case.

Using OR Logic

To check if text contains “invoice”, “receipt”, or “bill”:

=REGEXTEST(A2, "invoice|receipt|bill")

Returns: TRUE if any of the three words are present.

Detecting Disallowed Characters

To check for any characters that are NOT letters, numbers, or spaces:

=REGEXTEST(A2, "[^A-Za-z0-9 ]")

Returns: TRUE if any disallowed character is found.

Using Cell References for Pattern

If you store the pattern in cell B2:

=REGEXTEST(A2, B2)

This makes patterns easier to manage and reuse.

With Dynamic Arrays

REGEXTEST supports dynamic arrays. To test an entire range at once:

=REGEXTEST(A2:A100, "[0-9]")

Returns an array of TRUE/FALSE values for each cell in the range.


Practical Use Cases

ScenarioFormula
Check for digits=REGEXTEST(A2, "[0-9]")
Check for letters only=REGEXTEST(A2, "^[A-Za-z]+$")
Validate email format=REGEXTEST(A2, "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b")
Validate phone number=REGEXTEST(A2, "\(\d{3}\)\s\d{3}-\d{4}")
Check for 5 digits=REGEXTEST(A2, "\d{5}")
Check for punctuation=REGEXTEST(A2, "[[:punct:]]")
Case-insensitive search=REGEXTEST(A2, "text", 1)
OR logic=REGEXTEST(A2, "cat|dog|bird")

Notes

  • ✅ Fully tested – The implementation in Modern Functions Update works identically to Microsoft’s original function introduced in Microsoft 365.
  • ✅ The function is fully compatible with Excel 2007, 2010, and all later versions.
  • ℹ️ REGEXTEST uses the PCRE2 flavor of regular expressions.
  • ℹ️ The function is case-sensitive by default. Use 1 as the third argument for case-insensitive matching.
  • ℹ️ To test the entire text string as a single unit (not just a portion), use anchors ^ (start) and $ (end) in your pattern.

See Also

  • REGEXEXTRACT – Extracts text that matches a regex pattern
  • REGEXREPLACE – Replaces text that matches a regex pattern
  • TEXTBEFORE – Extracts text before a delimiter
  • TEXTAFTER – Extracts text after a delimiter
  • TEXTSPLIT – Splits text into multiple values
  • IFNA – Handles #N/A errors gracefully

Leave a comment