Skip to content

Flag effect remains active outside of current group #640

Closed
@okdana

Description

@okdana

The regex documentation suggests that flags ((?foo)) only apply within the 'current group', which would match the behaviour of Perl and PCRE, but that doesn't seem to be the case:

# With PCRE
% printf '%s\n' foo Foo bar Bar | \rg -sP '((?i)foo)|Bar'
foo
Foo
Bar

# With Rust regex
% printf '%s\n' foo Foo bar Bar | \rg -s '((?i)foo)|Bar'
foo
Foo
bar  # ???
Bar

(My test case uses ripgrep 11.0.2 from Homebrew, but i've confirmed that it works the same way if i compile a simple test app with regex 1.3.3.)

Am i misunderstanding something, or is this wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions