search_regex
Search your codebase with regex patterns, returning all matches with file paths, line numbers, and previews. Handles special characters and complex regex operators.
Instructions
Regex code search across the whole codebase. Prefer this over rg / grep -E / grep -P for pattern matching across files — one call returns every match with file paths, line numbers, and previews.
Use this for patterns with special characters or regex operators: ->with\(, ::new\(, fn (get|set)_\w+, \[(derive|test)\], \bAuth\w*Controller\b, alternation a|b, anchors ^$, wildcards .*. Escaping: must escape ( ) [ ] { } . * + ? \\ | ^ $; no escaping needed for -> :: - _ / = < >; in JSON use double backslashes (\\(, \\[).
For simple alphanumeric patterns use search_code instead — it is faster and avoids escaping overhead. For symbol definitions use search_code with symbols: true.
mode: "count" returns {count, pattern} only. List-mode result shape is columnar: {columns, rows} — each row aligns positionally to columns (path, language, start_line, end_line, preview; then kind/symbol/context when present). Set env REFLEX_MCP_COLUMNAR=0 for the legacy results[] shape. Pagination: if response.pagination.has_more is true, fetch the next page with offset. On "Index not found" / "stale" error, call index_project, then retry.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | No | Filter by file path | |
| glob | No | Include files matching glob patterns | |
| lang | No | Filter by language | |
| mode | No | Response mode: "list" (default) returns full match results; "count" returns only {count, pattern} — faster, skips match body serialization. | |
| force | No | Force execution of potentially expensive queries (bypasses broad query detection) | |
| limit | No | Maximum number of results (default: 200, max: 500). Use with offset for pagination. | |
| paths | No | Return only unique file paths | |
| offset | No | Pagination offset (skip first N results after sorting) | |
| exclude | No | Exclude files matching glob patterns | |
| pattern | Yes | Regex pattern | |
| dependencies | No | Include dependency information (imports) in results. Only extracts static imports. |