Struct stam::FindRegexMatch
source · pub struct FindRegexMatch<'store, 'r> { /* private fields */ }Expand description
This match structure is returned by the FindRegexIter iterator, which is in turn produced
by FindText::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<'store, 'r> FindRegexMatch<'store, 'r>
impl<'store, 'r> FindRegexMatch<'store, 'r>
sourcepub fn multi(&self) -> bool
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.
sourcepub fn expression(&self) -> &'r Regex
pub fn expression(&self) -> &'r Regex
Returns the regular expression that matched
sourcepub fn expression_index(&self) -> usize
pub fn expression_index(&self) -> usize
Returns the index of regular expression that matched
pub fn textselections(&self) -> &[ResultTextSelection<'store>]
pub fn resource(&self) -> &ResultItem<'store, TextResource>
sourcepub fn capturegroups(&self) -> &[usize]
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.
sourcepub fn as_str(&self) -> Option<&'store str>
pub fn as_str(&self) -> Option<&'store 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.
sourcepub fn text(&self) -> Vec<&str>
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.