Skip to content

Reverse suffix doesn't return the leftmost match when alternates overlap #1354

Description

@JakubValtar

What version of regex are you using?

1.12.3

Describe the bug at a high level.

The reverse suffix strategy doesn't return the leftmost match first when the first alternate overlaps with the second alternate.

What are the steps to reproduce the behavior?

use regex; // 1.12.3

fn main() {
    let r = regex::Regex::new(".abb|b").unwrap();

    let m = r.find("zabb").unwrap();

    assert_eq!(m.as_str(), "zabb")
}

https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=2273db01d4564806836a207fb7af5c52

What is the actual behavior?

The first match is "b".

What is the expected behavior?

The first match should be the leftmost match, "zabb".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    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