Skip to content

shortest_match does not match *shortest* #747

Closed
@mina86

Description

@mina86

What version of regex are you using?

1.4.3

Describe the bug at a high level.

The name shortest_match is misleading. It suggests the method will return shortest possible match. In reality that’s not the case. While I accept that it may be infeasible to change the code to make such guarantee, the name of the method should be changed. fastest_match? match_end?

What are the steps to reproduce the behavior?

extern crate regex;

use regex::Regex;

fn main() {
    println!("{}", Regex::new("ab|a").unwrap().shortest_match("ab").unwrap());
}

What is the actual behavior?

Prints 2.

What is the expected behavior?

Prints 1.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions