Skip to content

[Feature] use the fancy-regex crate in colgrep #54

@dlight

Description

@dlight

The fancy-regex crate builds upon regex to provide more matching features like lookarounds. It uses backtracking like PCRE, so it has some performance pitfalls, but this only applies in the regex parts where the user actually uses fancy features. If they don't use it anywhere, the regex is run straight by regex, with no performance penalty.

Those additional features are occasionally useful when searching for code, and since fancy-regex use a familiar syntax I think that agents would make use of it when needed (maybe with some adjustments to SKILL.md). For example (from the readme)

For example, the following regex captures a single-line Rust raw string:

r(#*)".*?"\1

There is no NFA that can express this simple and useful pattern. Yet, a backtracking implementation handles it efficiently.

Since fancy-regex reverts to regex when you don't use its additional features, it wouldn't be a breaking change to simply change the regex engine to it. But if one wants to be careful, this could be controlled by a fancy_regex feature flag (initially it could be disabled by default, and at a later date enabled by default).

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions