search_regex
Use regex patterns to search code for complex text matches, including wildcards, alternation, and special characters. Filter results by file, language, or glob patterns.
Instructions
Regex-based code search for complex pattern matching (e.g., 'fn (get|set)_\w+').
Use for:
Patterns with special characters: -> :: () [] {} . * + ? \ | ^ $
Pattern matching: wildcards (.*), alternation (a|b), anchors (^$)
Complex searches: case-insensitive variants, word boundaries
Common examples:
Method calls: '->with\(', '->map\(', '::new\('
Operators: '->', '::', '||', '&&'
Functions: 'fn (get|set)_\\w+' (getter/setter functions)
Attributes: '\\[(derive|test)\\]' (Rust attributes)
Escaping rules:
Must escape: ( ) [ ] { } . * + ? \ | ^ $
No escaping needed: -> :: - _ / = < >
Use double backslash in JSON: \\( \\) \\[ \\]
Error Handling: If you receive an error message containing "Index not found" or "stale", immediately call the index_project tool, wait for it to complete, then retry this operation.
Don't use for:
Simple text searches (use search_code instead - faster)
Symbol definitions (use search_code with symbols=true instead)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dependencies | No | Include dependency information (imports) in results. Only extracts static imports. | |
| exclude | No | Exclude files matching glob patterns | |
| file | No | Filter by file path | |
| force | No | Force execution of potentially expensive queries (bypasses broad query detection) | |
| glob | No | Include files matching glob patterns | |
| lang | No | Filter by language | |
| limit | No | Maximum number of results (use with offset for pagination) | |
| offset | No | Pagination offset (skip first N results after sorting) | |
| paths | No | Return only unique file paths | |
| pattern | Yes | Regex pattern |