Find text in a Google Doc
find_textLocate every occurrence of a phrase in a Google Doc and return exact start/end indexes, paragraph style, and table status for precise index-based edits.
Instructions
Find every occurrence of a literal phrase in a Google Doc (including text inside table cells) and return the exact startIndex/endIndex of each match, its paragraph style, whether it is in a table, and a short context snippet. Use this to get exact indexes for index-based tools such as format_text, delete_text, insert_link or insert_text. Matching is literal (no wildcards or regular expressions), case-insensitive unless matchCase is true, and a match cannot span paragraphs or include the paragraph’s line break. Indexes are only valid until the document is edited: when applying several edits, work from the last occurrence backwards.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | The exact text to find. | |
| matchCase | No | Match upper/lower case exactly (default: case-insensitive). | |
| 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. | |
| maxResults | No | Maximum number of occurrences to return (1-500). totalMatches always reports the full count. |