REGEXMATCH Function in Google Sheets: Syntax and Examples

REGEXMATCH tests whether text contains a regular-expression match and returns TRUE or FALSE. Anchors let you test an entire string rather than just a matching portion.

REGEXMATCH function syntax

=REGEXMATCH(text, regular_expression)
  • text: text input or reference.
  • regular_expression: RE2 pattern in quotes.

Set up the example data

Enter this small dataset starting in A1. The first row contains headers. Keep the formula output separate from the input cells.

Text
Order A17
PR-204
URGENT delivery
cat food
alex+tag@example.com

Check whether text contains digits

Enter this formula in A10. The character class matches any ASCII digit. One matching character anywhere in the cell is enough.

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

Result: TRUE.

REGEXMATCH example in Google Sheets, showing TRUE in the selected output.

Test the start of a code

The caret anchors the match to the start. A code containing PR only in the middle would fail this test.

=REGEXMATCH(A3,"^PR")

Result: TRUE.

Ignore capitalization

Putting the flag first makes the whole pattern case-insensitive. RE2 also supports scoped flags; the flag is not universally restricted to the start.

=REGEXMATCH(A4,"(?i)urgent")

Result: TRUE.

Match whole words from a list

Alternation accepts any listed animal. Word boundaries avoid matching cat inside a longer word such as catalogue.

=REGEXMATCH(A5,"(?i)\b(cat|dog|bird)\b")

Result: TRUE.

Check a basic email shape

This checks for non-space text on both sides of an at sign and a dot in the domain. It accepts plus tags.

=REGEXMATCH(A6,"^[^@\s]+@[^@\s]+\.[^@\s]+$")

Result: TRUE.

Handle empty text explicitly

Empty text does not contain a digit, so this test returns FALSE. An empty-text matching pattern can produce TRUE instead.

=REGEXMATCH("","[0-9]")

Result: FALSE.

Convert numeric input

Convert a number before passing it to REGEXMATCH. Google documents text-only input and RE2 support excluding Unicode character classes.

=REGEXMATCH(TO_TEXT(123),"[0-9]")

Result: TRUE.

Other Google Sheets articles you may also like