Skip to main content

RegexSetMatch

Struct RegexSetMatch 

Source
pub struct RegexSetMatch<'t, S: Input + ?Sized> { /* private fields */ }
Expand description

A match from a RegexSet, including the pattern index and capture groups.

This type represents a single match found by a RegexSet. It provides information about which pattern matched, the location of the match, and access to any capture groups.

§Examples

use fancy_regex::{RegexInput, RegexSet};

let set = RegexSet::new(&[r"\w+"])?;
let mut matches = set
    .find_input(RegexInput::new("abc"))?
    .expect("expected at least one match");

let m = matches.next().expect("expected first match")?;
assert_eq!(m.pattern(), 0);
assert_eq!(m.get().as_str(), "abc");
assert_eq!(m.start(), 0);
assert_eq!(m.end(), 3);
assert_eq!(m.captures().len(), 1);

Implementations§

Source§

impl<'t, S: Input + ?Sized> RegexSetMatch<'t, S>

Source

pub fn pattern(&self) -> usize

Returns the pattern index that matched.

Source

pub fn captures(&self) -> &Captures<'t, S>

Returns the full set of capture groups for this match.

Source

pub fn get(&self) -> S::Match<'t>

Returns the full match.

Source

pub fn start(&self) -> usize

Returns the start offset of the full match.

Source

pub fn end(&self) -> usize

Returns the end offset of the full match.

Source§

impl<'t> RegexSetMatch<'t, str>

Source

pub fn as_str(&self) -> &'t str

Returns the matched text.

Trait Implementations§

Source§

impl<'t, S: Debug + Input + ?Sized> Debug for RegexSetMatch<'t, S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'t, S> Freeze for RegexSetMatch<'t, S>
where S: ?Sized,

§

impl<'t, S> RefUnwindSafe for RegexSetMatch<'t, S>
where S: RefUnwindSafe + ?Sized,

§

impl<'t, S> Send for RegexSetMatch<'t, S>
where S: Sync + ?Sized,

§

impl<'t, S> Sync for RegexSetMatch<'t, S>
where S: Sync + ?Sized,

§

impl<'t, S> Unpin for RegexSetMatch<'t, S>
where S: ?Sized,

§

impl<'t, S> UnsafeUnpin for RegexSetMatch<'t, S>
where S: ?Sized,

§

impl<'t, S> UnwindSafe for RegexSetMatch<'t, S>
where S: RefUnwindSafe + ?Sized,

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

Source§

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

Source§

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.