Excel functions / Text

REGEXTEST function

TRUE if any part of the text matches a regular expression.

Syntax

=REGEXTEST(text, pattern, [case_sensitivity])

Arguments

When to use it

REGEXTEST is TRUE when a text matches a regular expression: a pattern that describes text, such as "five digits", "an email address" or "starts with INV-". It validates data that a simple comparison cannot.

Examples

  1. Is it a five-digit postcode?

    ABC
    1Postcode
    290210TRUE

    In C2: =REGEXTEST(A2, "^\d{5}

    quot;) → TRUE

    Try this example

  2. Does it look like an email address?

    ABC
    1Email
    2ana.example.comFALSE

    In C2: =REGEXTEST(A2, "^[^@\s]+@[^@\s]+\.[a-z]+

    quot;) → FALSE

    Try this example

Common mistakes

Try REGEXTEST in the playground

Practise it

Related functions