Regex Find and Replace in Google Docs (with Examples)
Regular expressions (regex) find patterns instead of fixed words: every date, every phone number, every double space. Google Docs has a "Match using regular expressions" option, but you can't see each match in context before you replace them all. FindSwap shows every match first.
Steps
- Install FindSwap from the Google Workspace Marketplace (button below). The free plan has no trial and no limits.
- Open your document and go to Extensions → FindSwap → Find & replace.
- The first time in each document, click Allow on this document and select it (it's shown first). FindSwap only opens documents you allow.
- Tick Regex, type the pattern in Find and the replacement in Replace with.
- Click Find. Every match is listed with the words around it. Untick any you want to keep.
- Click Replace selected. Undo is one click.
Useful patterns
| To do this | Find | Replace with |
|---|---|---|
| Change 2026-11-10 to 11/10/2026 | (\d{4})-(\d{2})-(\d{2}) | $2/$3/$1 |
| Collapse double spaces | {2,} (starts with a space) | one space |
| Remove a space before punctuation | +([,.;:!?]) (starts with a space) | $1 |
| Find phone numbers like 555-123-4567 | \d{3}-\d{3}-\d{4} | (preview only) |
| Swap "Last, First" to "First Last" | (\w+), (\w+) | $2 $1 |
FindSwap for Google Docs
Install freeFree forever: find, preview, replace, regex, clean-up and undo. Pro adds replacement lists, suggestions and formatting.
Questions
Does it support capture groups?
Yes: use $1, $2 and so on in the replacement, $& for the whole match, and $$ for a literal dollar sign.
Which regex flavor is it?
JavaScript regular expressions, the same syntax used across Google Apps Script.
Is regex free?
Yes. Regex find, preview and replace are in the free plan.