0Pricing
Excel Formulas Academy · Lesson

Testing Patterns With REGEXMATCH

Check whether text matches a pattern and return TRUE or FALSE.

Testing Patterns With REGEXMATCH is a free Excel Formulas Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Excel Formulas Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Why Patterns Beat Plain Search

Sometimes you do not want to check for one exact word. You want to ask a smarter question like does this cell contain any digits? or is this a valid email shape?

A regular expression (regex) is a tiny pattern language that describes the shape of text. Google Sheets lets you use it through three functions: REGEXMATCH, REGEXEXTRACT, and REGEXREPLACE.

In this lesson we focus on the first one. REGEXMATCH simply answers a yes or no question: does the text match the pattern?

The REGEXMATCH Syntax

REGEXMATCH takes two arguments: the text to check and the pattern to look for. It returns TRUE if the pattern is found anywhere in the text, otherwise FALSE.

Note: this function lives in Google Sheets. Excel uses different tools, so we are firmly in Sheets territory here.

The simplest pattern is just a piece of literal text. The formula below checks if cell A2 contains the word cat.

=REGEXMATCH(A2, "cat")

Matching Is Case Sensitive

By default regex matching cares about uppercase versus lowercase. The pattern cat will not match the text CAT.

To match either case you can list the options inside square brackets. [Cc]at matches both Cat and cat.

The formula below returns TRUE if A2 contains cat with the first letter in either case.

=REGEXMATCH(A2, "[Cc]at")

Anchors: Start and End

Regex gives you anchors to say where a pattern must sit.

  • ^ means the start of the text
  • $ means the end of the text

Without anchors, a match anywhere counts. With them you control position. The formula below is TRUE only when A2 starts with INV, which is handy for spotting invoice codes.

=REGEXMATCH(A2, "^INV")

Character Classes for Digits

A character class describes a group of allowed characters. The most common shortcut is \d, which means any single digit from 0 to 9.

The pattern below asks: does A2 contain at least one digit anywhere? The + means one or more, so it is TRUE for order7 and FALSE for hello.

=REGEXMATCH(A2, "\d+")

Worked Example: Find Cells With Numbers

Imagine column A holds product names. Some include a size like Shirt 12 and some do not. You want a TRUE/FALSE flag for which ones contain a number.

Drag the formula below down column B. Rows with any digit show TRUE; pure text rows show FALSE. You can then filter on that column.

=REGEXMATCH(A2, "\d")

Common Classes You Will Reuse

A few shortcuts cover most needs:

  • \d any digit
  • \w any letter, digit, or underscore
  • \s any whitespace such as a space or tab
  • . any single character at all

You can also build your own class. [A-Z] means any uppercase letter and [a-z] means any lowercase letter. The formula below checks whether A2 contains an uppercase letter.

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

Quantifiers Control How Many

Quantifiers say how many times the thing before them may repeat:

  • + one or more
  • * zero or more
  • ? zero or one (optional)
  • {3} exactly three

To check whether A2 is a five-digit ZIP code from start to end, combine anchors with an exact quantifier as shown below.

=REGEXMATCH(A2, "^\d{5}$")

Worked Example: Validate an Email Shape

You can flag cells that look like an email address. A rough but practical pattern is: some characters, an @, more characters, a dot, then a couple of letters.

The formula below returns TRUE for sam@site.com and FALSE for not-an-email. It is not perfect validation, but it catches obvious mistakes in a contact list.

=REGEXMATCH(A2, "^[\w.]+@[\w.]+\.\w{2,}$")

Combining REGEXMATCH With IF

Because REGEXMATCH returns TRUE or FALSE, it slots straight into an IF. That lets you show a friendly message instead of a bare boolean.

The formula below labels each cell as Has number or Text only depending on whether it contains a digit.

=IF(REGEXMATCH(A2, "\d"), "Has number", "Text only")

Escaping Special Characters

Some characters are special in regex: . + * ? ( ) [ ] ^ $ \ and a few more. If you want to match them literally, put a backslash in front.

To check for a literal dot, write \. rather than just . (which would match any character). The formula below is TRUE only if A2 actually contains a period.

=REGEXMATCH(A2, "\.")

Quick Check

Test your understanding of REGEXMATCH and patterns.

Recap: Yes or No With Patterns

You learned that REGEXMATCH(text, pattern) returns TRUE or FALSE in Google Sheets. Key ideas:

  • Patterns describe the shape of text, not just exact words
  • \d \w \s . are handy character shortcuts
  • ^ and $ anchor to start and end
  • + * ? {n} control how many times something repeats
  • Escape specials like \. to match them literally

Next you will move from testing patterns to pulling the matching text out with REGEXEXTRACT.

Frequently asked questions

Is the “Testing Patterns With REGEXMATCH” lesson free?

Yes — the full text of “Testing Patterns With REGEXMATCH” is free to read here on the web, and the Excel Formulas Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Excel Formulas Academy course, upgrade to CoddyKit PRO.

What will I learn in “Testing Patterns With REGEXMATCH”?

Check whether text matches a pattern and return TRUE or FALSE. You practise Excel Formulas Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Excel Formulas Academy?

No prior experience is required. Excel Formulas Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Testing Patterns With REGEXMATCH” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Excel Formulas Academy lesson?

Yes. Every Excel Formulas Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Testing Patterns With REGEXMATCH
  2. Pulling Out Patterns With REGEXEXTRACT
  3. Replacing Patterns With REGEXREPLACE
  4. Splitting and Cleaning Messy Data
← Back to Excel Formulas Academy