How to Clean Messy Spreadsheet Data with Google Sheets Regex

Use Google Sheets regex functions to create a separate cleaned or review column while keeping the original data unchanged. REGEXEXTRACT returns matching text, REGEXREPLACE transforms text, and REGEXMATCH flags whether a pattern exists. Test a representative sample before filling a formula down a production sheet.

Choose the function that matches the job

FunctionUse it forCommon mistake
REGEXEXTRACTReturn the first text matching a patternAssuming it returns every match
REGEXREPLACERemove or rewrite matching textOverwriting the only copy of the source
REGEXMATCHFlag rows for validation or reviewTreating a match as proof that the whole value is valid

Extract a simple email-like value

=IFERROR(REGEXEXTRACT(A2,"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}"),"")

This is useful for finding a likely email-shaped substring in ordinary text. It is not a complete validation of every address allowed by email standards and does not prove the mailbox exists.

Normalize phone text without inventing a country format

=REGEXREPLACE(A2,"[^0-9+]","")

The formula removes spaces, parentheses, and hyphens while retaining digits and plus signs. It does not determine country code, national trunk prefix, extension, or whether the number is valid. Keep the original and use region-specific validation when the number has business consequences.

Flag values that require manual review

=IF(REGEXMATCH(A2,"^[A-Z]{3}-[0-9]{5}$"),"OK","REVIEW")

This example expects three uppercase letters, a hyphen, and five digits. Anchors ^ and $ matter because without them a valid-looking substring inside a longer invalid value can still match.

Use capture groups deliberately

=REGEXEXTRACT(A2,"^([A-Z]{3})-([0-9]{5})$")

Capture groups can return multiple columns. Before filling down, place the formula where the spilled result has room and confirm that blank or malformed rows are handled with IFERROR.

Remember the engine limits

Google Sheets documents that its regex functions use the RE2 engine and do not support Unicode character-class matching. Patterns copied from another regex tool may use features that Sheets does not accept or may behave differently. Test the actual formula in Sheets rather than validating only in a separate website.

Do not convert identifiers by accident

Cleaned phone numbers, ZIP codes, case numbers, and product IDs are often text, not quantities. Format the destination column as Plain text before replacing values when leading zeros or long digit strings must remain exact. The guide How to Stop Google Sheets from Changing Numbers to Dates explains the related data-type issue.

Use a safer cleanup layout

  1. Keep the original in column A.
  2. Put the proposed cleaned value in column B.
  3. Put an OK/REVIEW result in column C.
  4. Filter REVIEW rows and inspect several edge cases.
  5. Compare counts, blanks, and duplicates before replacing anything.
  6. Paste values only after the result is accepted.

Example before-and-after review

OriginalProposed outputDecision
+1 (555) 010-2040+15550102040Review country/extension rules
ABC-00123ABC-00123Keep as text
no address suppliedblankManual follow-up

Completion checklist

Official Google references

Related Guides

About the author

Tweaknook Editorial publishes practical guides and browser-based tools for everyday digital work. Product-dependent facts are checked against current primary documentation, with limitations and safer verification steps stated where relevant.