How to Use Regex in Google Sheets
Published April 2025 · 5 min read
REGEXMATCH — Check if text matches
=REGEXMATCH(A1, "[0-9]+") // Contains numbers?
=REGEXMATCH(A1, "^[A-Z]") // Starts with uppercase?
=REGEXMATCH(A1, "@gmail\.com") // Is Gmail?
REGEXEXTRACT — Pull out matching text
=REGEXEXTRACT(A1, "[0-9]+") // Extract first number
=REGEXEXTRACT(A1, "([a-z]+)@") // Extract email username
=REGEXEXTRACT(A1, "\$([0-9,.]+)") // Extract price
REGEXREPLACE — Find and replace with regex
=REGEXREPLACE(A1, "[^0-9]", "") // Keep only numbers
=REGEXREPLACE(A1, "\s+", " ") // Remove extra spaces
=REGEXREPLACE(A1, "^(.{50}).*", "$1") // Truncate to 50 chars
Practical Examples
- Extract domain from email:
=REGEXEXTRACT(A1, "@(.+)") - Validate phone number:
=REGEXMATCH(A1, "^\d{10}$") - Remove HTML tags:
=REGEXREPLACE(A1, "<[^>]+>", "")
Test Your Regex First
Use our Regex Tester to build and test patterns before using them in Sheets.