pub struct Captures<'t> { /* private fields */ }
Expand description
Captures represents a group of captured strings for a single match.
The 0th capture always corresponds to the entire match. Each subsequent index corresponds to the next capture group in the regex. Positions returned from a capture group are always byte indices.
't
is the lifetime of the matched text.
Implementations
sourceimpl<'t> Captures<'t>
impl<'t> Captures<'t>
sourcepub fn pos(&self, pos: usize) -> Option<(usize, usize)>
pub fn pos(&self, pos: usize) -> Option<(usize, usize)>
Returns the start and end positions of the Nth capture group. Returns
None
if i is not a valid capture group or if the capture group did
not match anything. The positions returned are always byte indices with
respect to the original string matched.
sourcepub fn at(&self, pos: usize) -> Option<&'t str>
pub fn at(&self, pos: usize) -> Option<&'t str>
Returns the matched string for the capture group i
. If i
isn’t
a valid capture group or didn’t match anything, then None
is returned.
sourcepub fn iter(&'t self) -> SubCaptures<'t>ⓘNotable traits for SubCaptures<'t>impl<'t> Iterator for SubCaptures<'t> type Item = Option<&'t str>;
pub fn iter(&'t self) -> SubCaptures<'t>ⓘNotable traits for SubCaptures<'t>impl<'t> Iterator for SubCaptures<'t> type Item = Option<&'t str>;
Creates an iterator of all the capture groups in order of appearance in the regular expression.
sourcepub fn iter_pos(&'t self) -> SubCapturesPos<'t>ⓘNotable traits for SubCapturesPos<'t>impl<'t> Iterator for SubCapturesPos<'t> type Item = Option<(usize, usize)>;
pub fn iter_pos(&'t self) -> SubCapturesPos<'t>ⓘNotable traits for SubCapturesPos<'t>impl<'t> Iterator for SubCapturesPos<'t> type Item = Option<(usize, usize)>;
Creates an iterator of all the capture group positions in order of appearance in the regular expression. Positions are byte indices in terms of the original string matched.
Trait Implementations
Auto Trait Implementations
impl<'t> RefUnwindSafe for Captures<'t>
impl<'t> !Send for Captures<'t>
impl<'t> !Sync for Captures<'t>
impl<'t> Unpin for Captures<'t>
impl<'t> UnwindSafe for Captures<'t>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more