REGEX functions practice exercises

The REGEX functions use regular expressions to test, pull out or clean up text. They are the fastest way to grab email domains, keep only digits from phone numbers, or check whether a value matches a pattern.

Syntax

REGEXMATCH(text, pattern)  ·  REGEXEXTRACT(text, pattern)  ·  REGEXREPLACE(text, pattern, replacement)
REGEXMATCH
TRUE if the text contains the pattern.
REGEXEXTRACT
Returns the part that matches, or the part inside ( ) if you use a capture group.
REGEXREPLACE
Replaces every match with the replacement text.

The practice data

Messy contact data: names, emails and phone numbers in mixed formats. Every exercise below uses this sheet, and your answer goes in H2.

ABC
1NameEmailPhone
2Ana Lopez[email protected](214) 555-0182
3Ben Ortiz[email protected]972-555-0147
4Cara Smith[email protected](469) 555-0123
5Dev Patel[email protected]214.555.0199

Worked example

=REGEXEXTRACT(B2,"@(.+)")

The capture group returns everything after the @: the email domain. Result:

acme.com

Your turn: 3 exercises

Type a formula and press Enter. It is checked by a real formula engine, so any correct approach counts.

1 Return TRUE if the email in B3 ends in .io.

H2

2 Return just the first name from A5.

H2

3 Return the phone number in C2 with only digits.

H2

Master REGEX functions in the full course

Lesson 18 of 18 goes deeper, with more exercises in a real spreadsheet grid. Start with the first 4 lessons free, then unlock everything with Pro.

Start free See pricing

Common REGEX functions mistakes

FAQ

Which regex syntax does Google Sheets use?

Google's RE2 syntax. It supports most common patterns, but not look-behinds.

Are REGEX functions case-sensitive?

Yes. Add (?i) at the start of the pattern to ignore case.

Keep practicing