pub struct Match {
pub range: Range,
pub captures: Vec<Option<Range>>,
/* private fields */
}
Expand description
A Match represents a portion of a string which was found to match a Regex.
Fields§
§range: Range
The total range of the match. Note this may be empty, if the regex matched an empty string.
captures: Vec<Option<Range>>
The list of captures. This has length equal to the number of capturing groups in the regex. For each capture, if the value is None, that group did not match (for example, it was in a not-taken branch of an alternation). If the value is Some, the group did match with the enclosed range.
Implementations§
source§impl Match
impl Match
sourcepub fn group(&self, idx: usize) -> Option<Range>
pub fn group(&self, idx: usize) -> Option<Range>
Access a group by index, using the convention of Python’s group() function. Index 0 is the total match, index 1 is the first capture group.
sourcepub fn named_group(&self, name: &str) -> Option<Range>
pub fn named_group(&self, name: &str) -> Option<Range>
Access a named group by name.
sourcepub fn named_groups(&self) -> NamedGroups<'_> ⓘ
pub fn named_groups(&self) -> NamedGroups<'_> ⓘ
Return an iterator over the named groups of a Match.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Match
impl RefUnwindSafe for Match
impl Send for Match
impl Sync for Match
impl Unpin for Match
impl UnwindSafe for Match
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more