Skip to content

improve --smart-case once and for all #851

@BurntSushi

Description

@BurntSushi

We should improve the --smart-case flag to be perfect or nearly perfect at least. The regex-syntax crate rewrite now has a more detailed AST, which permits us to handle cases like [A-Z] and \p{Ll} differently. In particular, I propose:

When the --smart-case flag is given, ripgrep chooses to match case insensitively if and only if there is at least one literal character in the pattern and that all such literals are not considered as uppercase. If the pattern contains no literals or at least one uppercase literal character, then normal case sensitive search is used.

Examples: abc, [a-z], abc\w and abc\p{Ll} are all searched case insensitively while aBc, [A-Z], aBc\w and \p{Ll} are searched case sensitively.

See also: #717 (comment)

cc @okdana

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementAn enhancement to the functionality of the software.libripgrepAn issue related to modularizing ripgrep into libraries.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions