Struct stam::FindRegexMatch

source ·
pub struct FindRegexMatch<'t, 'r> { /* private fields */ }
Expand description

This match structure is returned by the FindRegexIter iterator, which is in turn produced by [TextResource.find_text_regex()] and searches a text based on regular expressions. This structure represents a single regular-expression match of the iterator on the text.

Implementations§

source§

impl<'t, 'r> FindRegexMatch<'t, 'r>

source

pub fn multi(&self) -> bool

Does this match return multiple text selections? Multiple text selections are returned only when the expression contains multiple capture groups.

source

pub fn expression(&self) -> &'r Regex

Returns the regular expression that matched

source

pub fn expression_index(&self) -> usize

Returns the index of regular expression that matched

source

pub fn textselections(&self) -> &[WrappedItem<'t, TextSelection>]

source

pub fn resource(&self) -> &'t TextResource

source

pub fn capturegroups(&self) -> &[usize]

Records the number of the capture groups (1-indexed!) that match. This array has the same length as textselections and identifies precisely which textselection corresponds with which capture group.

source

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

Return the text of the match, this only works if the regular expression targets a single consecutive text, i.e. by not using multiple capture groups.

source

pub fn text(&self) -> Vec<&str>

This returns a vector of texts and is mainly useful in case multiple patterns were captured. Use Self::as_str() instead if you expect only a single text item.

Auto Trait Implementations§

§

impl<'t, 'r> RefUnwindSafe for FindRegexMatch<'t, 'r>

§

impl<'t, 'r> Send for FindRegexMatch<'t, 'r>

§

impl<'t, 'r> Sync for FindRegexMatch<'t, 'r>

§

impl<'t, 'r> Unpin for FindRegexMatch<'t, 'r>

§

impl<'t, 'r> UnwindSafe for FindRegexMatch<'t, 'r>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V