Find and replace text
replace_all_textReplace every occurrence of a literal string throughout a Google Doc, or only within specified tabs. Returns the number of replacements, making it easy to verify if the text was found.
Instructions
Replaces EVERY occurrence of a literal string (no regex) across the whole document, or only in the tabs named by tab_ids. match_case defaults to true. Returns occurrencesChanged in the batchUpdate reply — 0 means the text was not found, not an error. Safer than replace_range for textual substitutions because it does not depend on indexes; use replace_range when position matters (e.g. only one of several occurrences).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| find | Yes | The literal text to find (no regex). | |
| replace | Yes | The replacement text; empty string deletes the occurrences. | |
| tab_ids | No | Limit the replacement to these tabs (from list_tabs); omit for all tabs. | |
| match_case | No | Case-sensitive matching (default true). | |
| document_id | Yes | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |