Skip to content

Pre-defined search pattern contributions #1

Closed
@genivia-inc

Description

You can help improving ugrep by contributing your search patterns. By sharing your search patterns you are helping the community of "greppers" to improve their source code search skills and results.

I've defined some common search patterns for C, C++, Java, JS, JSON, Markdown, PHP, Python, Ruby, and XML (see the patterns directory README's). This is good starting point.

What is a pattern file?

Pattern files are used with option -f. Pattern files contain regex patterns. Any pattern that matches is part of the search results, except for "negative patterns" (see below). Comments start at the first column with a hash #. To start a pattern with a hash, use \#. Patterns that require multi-line matching should have a first line with ###-o to implicitly enable option -o. Empty lines in pattern files are ignored and can be used together with comments to organize the file contents. For POSIX matching (the default) the order of the patterns in the file does not matter. For Perl matching with option -P, the order matters.

What are "negative patterns"?

Note that patterns may include "negative patterns" such as zap_comments and zap_strings to skip comments and strings to improve the accuracy of search results. For example, ugrep -r -tc++ some_function -n -o -f c++/zap_comments searches lines matchingsome_function in the working directory C++ source code files. A negative pattern has the form (?^X) where X should not be matched to generate search results. Negative patterns cannot be used with option -P (Perl matching).

Questions?

For questions please comment.

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions