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.
| A | B | C | |
|---|---|---|---|
| 1 | Name | Phone | |
| 2 | Ana Lopez | [email protected] | (214) 555-0182 |
| 3 | Ben Ortiz | [email protected] | 972-555-0147 |
| 4 | Cara Smith | [email protected] | (469) 555-0123 |
| 5 | Dev 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.
2 Return just the first name from A5.
3 Return the phone number in C2 with only digits.
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 pricingCommon REGEX functions mistakes
- Forgetting to escape special characters like
.,(and$with a backslash. - Using REGEX functions on numbers. They need text, so wrap numbers in TO_TEXT first.
- Expecting REGEXEXTRACT to return all matches. It returns the first one.
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.