Replace text in Google Doc
replace_textReplace every occurrence of a text string throughout an entire Google Doc with new text in one operation, or delete all matches by supplying an empty replacement.
Instructions
Replace ALL occurrences of searchText throughout the entire Google Doc with replacementText, in one operation. An empty replacementText DELETES every occurrence. Matching is plain text (no regular expressions) and case-insensitive unless matchCase is true, so a short search such as "an" may also match inside other words. If the search text is short or could match more than intended, preview the matches with find_text first, and use insert_text/delete_text for a single occurrence. Returns occurrencesChanged (0 means nothing matched and the document is unchanged). Indexes after each changed occurrence shift when the lengths differ. No index is needed.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| matchCase | No | Only replace matches with exactly the same upper/lower case (default false). | |
| documentId | Yes | The Google Docs document ID (the part between /d/ and /edit in the document URL). A full Google Docs URL is also accepted. | |
| searchText | Yes | The exact text to search for (not a regular expression). | |
| replacementText | Yes | Text that replaces every match. An empty string deletes every match. |