Write Google Sheets REGEX Formulas to Extract and Clean Text
Get ready-to-paste REGEXEXTRACT, REGEXREPLACE, or REGEXMATCH formulas for Google Sheets with a token-by-token breakdown.
Text prompt for Gemini and ChatGPT
You get: Formula, how It Works and edge Cases
Prompt
Act as a Google Sheets formula specialist. I will paste 3 to 5 sample text strings and tell you whether I need to extract, replace, or match a pattern.
Write the exact Google Sheets formula using REGEXEXTRACT, REGEXREPLACE, or REGEXMATCH. Follow these rules:
1. Use RE2-compatible regular expression syntax, because Google Sheets does not support lookbehinds or backreferences.
2. Wrap the formula in IFERROR so non-matching cells return a blank string instead of an error.
3. Keep the pattern as simple and readable as possible while handling all provided edge cases.
4. Assume the input text is in cell A2 unless I specify another cell.
Output format:
- **Formula:** The complete, ready-to-paste Google Sheets formula.
- **How It Works:** A token-by-token breakdown of the regular expression in a short bulleted list.
- **Edge Cases:** One or two variations that could break the pattern and how to adjust for them.
End with one line stating any assumptions made about spaces, capitalization, or missing characters.Example output
Tips and common edits
Why this works
- Enforces RE2 syntax so the generated pattern never uses unsupported lookbehinds.
- Wraps formulas in IFERROR to keep messy columns free of #N/A errors.
- Includes a token-by-token breakdown so you can tweak the pattern yourself later.
Paste 3 to 5 sample strings and describe what you want to extract, replace, or match. Works in Gemini, ChatGPT, or Claude.
Common edits
- Ask for an ARRAYFORMULA wrapper if you want one formula to process an entire column.
- Specify case-insensitivity if your source text mixes uppercase and lowercase letters.
Reuse it: Use in a workflowTurn into a skillAdapt in the builder
Prompt details
- By
- Prompts-GPT editors
- Published
Did this prompt work?
More like this
Deduplicate spreadsheet rows keeping latest entry
Finds duplicate records in your data and generates clean formulas or step-by-step instructions to keep only the newest record.
Clean phone numbers and postal codes using Excel formulas
Transform irregular contact details into uniform formats for clean CRM imports. Use this whenever raw exports mix dashes, dots, spaces, or leading zeroes.
Parse Unstructured Text into Clean Excel Columns
This prompt generates specific Excel formulas to split messy text strings into organized columns while handling edge cases like missing delimiters.
Clean and Standardize Messy Spreadsheet Data with Exact Formulas
Get a column-by-column cleaning plan with ready-to-fill formulas for spaces, case, dates and duplicates, plus a list of rows that need a manual check.
Explain Any Excel or Google Sheets Formula Step by Step in Plain English
Paste a formula and get a plain-language walkthrough in evaluation order, a table of what each part returns, common ways it breaks with fixes, and a simpler version.
Pick XLOOKUP, VLOOKUP or INDEX MATCH and Get the Exact Formula
You get one recommended lookup method for your Excel version and data layout, a paste-ready formula, and clear handling for values that have no match.
- Write an Excel or Google Sheets Formula from Plain English
- Consolidate separate spreadsheet tabs into a master rollup
- Strip hidden characters and non-printing breaks in Excel
- Build a 3D sum formula across multiple monthly tabs
- Fix divide-by-zero errors in Excel variance formulas
- Convert dragged Google Sheets formulas to ARRAYFORMULA