Skip to content

Unexpected behavior of ungreedy ?? operator #862

Closed
@vthib

Description

@vthib

What version of regex are you using?

1.5.5

Describe the bug at a high level.

Running the regex ab?? on the input ab returns the match ab instead of a.

What are the steps to reproduce the behavior?

fn main() {
    let rx = regex::Regex::new("ab??").unwrap();
    let input = "ab";
    let mat = rx.find(input).unwrap();
    println!("match: {}", &input[mat.range()]);
}

What is the actual behavior?

This program returns: ab

What is the expected behavior?

I expect the output to be a, since ?? is non greedy, it should favor not matching the second letter in the input.

All other implementations i could find matches on a only.

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