[][src]Struct regress::Match

pub struct Match {
    pub range: Range,
    pub captures: Vec<Option<Range>>,

A Match represents a portion of a string which was found to match a Regex.


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.


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>;

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]

impl Debug for Match[src]

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

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

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

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

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

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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.