The standard “Find and Replace” tool in Google Docs is great for swapping one specific word for another. But what if you need to find all instances of phone numbers, email addresses, or words that end in a specific suffix? Instead of manually searching for every variation, you can use Regular Expressions (Regex) to perform advanced, pattern-based searches directly within your document.
How to Enable Regular Expressions in Google Docs
By default, Google Docs treats your search queries as literal text. You have to explicitly tell the search tool to interpret your query as a Regex pattern.
- Open your document in Google Docs.
- Click on Edit in the top menu bar, and select Find and replace (or use the keyboard shortcut Ctrl+H on Windows or Cmd+Shift+H on Mac).
- In the pop-up window, check the box labeled Match using regular expressions.
- The “Match case” box will automatically be checked and greyed out, as Regex searches in Google Docs are case-sensitive by default.
Examples of Regex Patterns You Can Use
Once Regex is enabled, you can type patterns into the “Find” box. Here are a few highly useful patterns you can use to clean up your documents:
- Find any email address: Type
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}to instantly highlight every email address in the document. - Find all numbers: Type
\d+to find any sequence of digits (useful for finding years, prices, or statistics). - Find extra spaces: Type
{2,}(a space followed by {2,}) to find places where you accidentally typed double or triple spaces between sentences. You can then put a single space in the “Replace with” box and click “Replace all” to fix the document formatting instantly.
When using the “Replace” function with Regex, you cannot use Regex patterns in the “Replace with” box—that box only accepts literal text replacements.