Describe your feature request
I want to be able to do find_at, captures_at etc, but without searching beyond the start index.
The reason I'm not happy with &Regex::new(r"^bar").find(&str[index..]) is the match range starts at 0, not at index. I want a Match whose range corresponds to the original string, not a slice.
I'm new to Rust, so maybe there's a smarter way to do this, but I'm trying to adapt a parsing approach I've used in other languages like
pub struct ParseState {
str: String,
idx: usize,
}
pub trait Parser {
fn peek<'h>(&'h self, regex: &Regex) -> Option<Match<'h>>;
fn find<'h>(&'h mut self, regex: &Regex) -> Option<Match<'h>>;
}
Where peek returns a Match if it exists at the current idx, and find does the same, but also advances the idx if found.
I've been able to use a sticky flag for this purpose in other languages. I wish I could just shift the Match range myself but Match::new is private. This is feeling pretty inconvenient. Seems like I'm going to have to go to the trouble to make some wrapper structs and implementations that apply the offset.
Describe your feature request
I want to be able to do
find_at,captures_atetc, but without searching beyond the start index.The reason I'm not happy with
&Regex::new(r"^bar").find(&str[index..])is the match range starts at 0, not atindex. I want aMatchwhose range corresponds to the original string, not a slice.I'm new to Rust, so maybe there's a smarter way to do this, but I'm trying to adapt a parsing approach I've used in other languages like
Where
peekreturns aMatchif it exists at the currentidx, andfinddoes the same, but also advances theidxif found.I've been able to use a sticky flag for this purpose in other languages. I wish I could just shift the
Matchrange myself butMatch::newis private. This is feeling pretty inconvenient. Seems like I'm going to have to go to the trouble to make some wrapper structs and implementations that apply the offset.