Struct regress::Match[][src]

pub struct Match {
    pub range: Range,
    pub captures: Vec<Option<Range>>,
}
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

impl Match[src]

pub fn group(&self, idx: usize) -> Option<Range>[src]

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.

pub fn range(&self) -> Range[src]

Returns the range over the starting and ending byte offsets of the match in the haystack.

This is a convenience function to work around the fact that Range does not support Copy.

pub fn start(&self) -> usize[src]

Returns the starting byte offset of the match in the haystack.

pub fn end(&self) -> usize[src]

Returns the ending byte offset of the match in the haystack.

pub fn groups(&self) -> Groups<'_>

Notable traits for Groups<'m>

impl<'m> Iterator for Groups<'m> type Item = Option<Range>;
[src]

Return an iterator over a Match. The first returned value is the total match, and subsequent values represent the capture groups.

Trait Implementations

impl Clone for Match[src]

fn clone(&self) -> Match[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Match[src]

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl RefUnwindSafe for Match

impl Send for Match

impl Sync for Match

impl Unpin for Match

impl UnwindSafe for Match

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.