search_and_replace_note
Replace text in TriliumNext notes using search patterns. Update note content by specifying search and replacement text, with regex support and version safety checks.
Instructions
Search and replace content within a single note. When someone wants to replace text in a note, first call get_note to get the current content and hash, then use this function to make the changes. This ensures you're working with the latest version of their note.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| noteId | Yes | ID of the note to perform search and replace on | |
| searchPattern | Yes | What to search for in the note. | |
| replacePattern | Yes | What to replace it with. For regex: supports patterns like '$1' for captured groups. | |
| useRegex | No | Whether to use regex patterns (default: true). | |
| searchFlags | No | Search options. Defaults to 'gi' (global, case-insensitive). Remove 'i' for exact case matching. | gi |
| expectedHash | Yes | ⚠️ REQUIRED: Content hash from get_note response. Always get the note content first to obtain this hash. | |
| revision | No | Whether to create a backup before replacing (default: true for safety). |