search_for_pattern
Identify and extract patterns in project files using regex. Specify context lines, include/exclude files with glob patterns, and target code files only. Returns matches with file paths and contextual lines in JSON format.
Instructions
Search for a pattern in the project. You can select whether all files or only code files should be searched. Generally, symbolic operations like find_symbol or find_referencing_symbols should be preferred if you know which symbols you are looking for. Returns A JSON object mapping file paths to lists of matched consecutive lines (with context, if requested).
Input Schema
Name | Required | Description | Default |
---|---|---|---|
context_lines_after | No | Number of lines of context to include after each match. | |
context_lines_before | No | Number of lines of context to include before each match. | |
max_answer_chars | No | If the output is longer than this number of characters, no content will be returned. Don't adjust unless there is really no other way to get the content required for the task. Instead, if the output is too long, you should make a stricter query. | |
only_in_code_files | No | Whether to search only in code files or in the entire code base. The explicitly ignored files (from serena config and gitignore) are never searched. | |
paths_exclude_glob | No | Optional glob pattern specifying files to exclude from the search (takes precedence over paths_include_glob). | |
paths_include_glob | No | Optional glob pattern specifying files to include in the search; if not provided, search globally. | |
pattern | Yes | Regular expression pattern to search for, either as a compiled Pattern or string. |