Struct onig::Captures

source ·
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§

source§

impl<'t> Captures<'t>

source

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.

source

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.

source

pub fn len(&self) -> usize

Returns the number of captured groups.

source

pub fn is_empty(&self) -> bool

Returns true if and only if there are no captured groups.

source

pub fn iter(&'t self) -> SubCaptures<'t>

Creates an iterator of all the capture groups in order of appearance in the regular expression.

source

pub fn iter_pos(&'t self) -> SubCapturesPos<'t>

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.

source

pub fn offset(&self) -> usize

Offset of the captures within the given string slice.

Trait Implementations§

source§

impl<'t> Debug for Captures<'t>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'t> Freeze for Captures<'t>

§

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§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.