Replace in Note
replace_in_noteReplace text in a note using literal strings or regex patterns. Optionally set an expected match count to prevent accidental over-replacement.
Instructions
Search-and-replace within a single note. Supports literal strings or regex patterns. With expectedCount, the operation refuses to commit unless that many matches are present, guarding against accidental over-replacement when an LLM drafts a pattern that's too broad. Returns the count of replacements made.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| find | Yes | Literal string (default) or regex pattern to match. | |
| path | Yes | Vault-relative path to the note. | |
| flags | No | Regex flags (e.g., 'gi'). Defaults to 'g' so all matches are replaced. | |
| regex | No | Treat `find` as a JavaScript regex (multi-line, case-sensitive by default). | |
| replace | Yes | Replacement text. With `regex: true`, supports $1, $2 backreferences. | |
| expectedCount | No | If set, abort unless exactly this many matches are found. |