ashlr__search_replace_regex
Regex-based search and replace across multiple files. Returns a diff summary and match count — not the full file contents.
ashlr__search_replace_regex applies a regex search-and-replace across one or more files and returns a compact diff summary (changed lines only). Use it for bulk renames or pattern-based transforms that span multiple files when ashlr__edit_structural doesn't apply (non-TS/JS files, or regex logic that can't be expressed as a symbol rename).
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
pattern | string | yes | Regex pattern to search for (ECMAScript regex syntax). |
replacement | string | yes | Replacement string (supports $1, $2 capture group refs). |
paths | string[] | yes | List of file paths or glob patterns to apply the replace to. |
flags | string | no | Regex flags (default: g). Add i for case-insensitive. |
Example
Returns
A compact diff summary:
When to use ashlr__edit_structural instead
For TypeScript/TSX/JS/JSX symbol renames (functions, classes, variables), prefer ashlr__edit_structural — it is scope-aware and won't rename occurrences that shadow the target symbol.
Typical savings
−80% vs ashlr__multi_edit with N edits — one call covers all files, and only match counts + diff lines are returned.
Related
ashlr__edit— single-file literal search/replaceashlr__multi_edit— batch literal editsashlr__edit_structural— AST-aware rename- Capabilities matrix