Skip to content

Method longest_match #791

Closed
Closed
@symil

Description

@symil

There is is_match that checks if there is a match for the given string, there is shortest_match that checks if there is a match and returns the length of the shortest match, but no method that checks if there is a match and returns the length of the longest match.

Re-using the shortest_match example, we would have:

let text = "aaaaa";
let pos = Regex::new(r"a+").unwrap().longest_match(text);
assert_eq!(pos, Some(5));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions