Skip to main content

PatternCapture

Trait PatternCapture 

Source
pub trait PatternCapture<'a> {
Show 13 methods // Required methods fn pattern_captures( &'a self, pattern: &str, case_insensitive: bool, ) -> Option<Captures<'a>>; fn pattern_matches_as_vec( &'a self, pattern: &str, case_insensitive: bool, outer: bool, ) -> Vec<Match<'a>>; fn pattern_first_match( &'a self, pattern: &str, case_insensitive: bool, ) -> Option<Match<'a>>; // Provided methods fn pattern_matches_vec( &'a self, pattern: &str, case_insensitive: bool, ) -> Vec<Match<'a>> { ... } fn pattern_matches_outer( &'a self, pattern: &str, case_insensitive: bool, ) -> Vec<Match<'a>> { ... } fn pattern_last_match( &'a self, pattern: &str, case_insensitive: bool, ) -> Option<Match<'a>> { ... } fn pattern_first_last_matches( &'a self, pattern: &str, case_insensitive: bool, ) -> Option<(Match<'a>, Match<'a>)> { ... } fn pattern_first_index( &'a self, pattern: &str, case_insensitive: bool, ) -> Option<usize> { ... } fn pattern_first_end_index( &'a self, pattern: &str, case_insensitive: bool, ) -> Option<usize> { ... } fn pattern_last_start_index( &'a self, pattern: &str, case_insensitive: bool, ) -> Option<usize> { ... } fn pattern_last_index( &'a self, pattern: &str, case_insensitive: bool, ) -> Option<usize> { ... } fn count_pattern( &'a self, pattern: &'a str, case_insensitive: bool, ) -> usize { ... } fn count_word(&'a self, word: &'a str, case_insensitive: bool) -> usize { ... }
}
Expand description

Set of methods to capture groups or match objects derived from Regex::captures.

Required Methods§

Source

fn pattern_captures( &'a self, pattern: &str, case_insensitive: bool, ) -> Option<Captures<'a>>

Yields an option with Regex::Captures as returned from re.captures, Accepts a boolean case_insensitive flag

Source

fn pattern_matches_as_vec( &'a self, pattern: &str, case_insensitive: bool, outer: bool, ) -> Vec<Match<'a>>

Yields a vector of Match objects with two modes, outer will whole groups only, otherwise uniqe matched groups and subgroups Use either pattern_matches_vec or pattern_matches_outer

Source

fn pattern_first_match( &'a self, pattern: &str, case_insensitive: bool, ) -> Option<Match<'a>>

Yields an option with first match object if available with a boolean case_insensitive flag As this uses re.find it will be fast than the matching last_match method

Provided Methods§

Source

fn pattern_matches_vec( &'a self, pattern: &str, case_insensitive: bool, ) -> Vec<Match<'a>>

Yields a vector of Match objects with start and end index + the captured string. Accepts a boolean case_insensitive flag Unlike pattern_captures, this method will only return unique matches including subgroups

Source

fn pattern_matches_outer( &'a self, pattern: &str, case_insensitive: bool, ) -> Vec<Match<'a>>

Yields a vector of Match objects with start and end index + the captured string. Accepts a boolean case_insensitive flag Unlike pattern_captures, this method will only outer matches for whole pattern

Source

fn pattern_last_match( &'a self, pattern: &str, case_insensitive: bool, ) -> Option<Match<'a>>

Yields an option with last match object if available with a boolean case_insensitive flag

Source

fn pattern_first_last_matches( &'a self, pattern: &str, case_insensitive: bool, ) -> Option<(Match<'a>, Match<'a>)>

returns an option with a pair of match objects If there is only one match the match objects will have the same indices

Source

fn pattern_first_index( &'a self, pattern: &str, case_insensitive: bool, ) -> Option<usize>

Yields an option with an unsigned integer for the index of the start of the last match with a boolean case_insensitive flag

Source

fn pattern_first_end_index( &'a self, pattern: &str, case_insensitive: bool, ) -> Option<usize>

Yields an option with an unsigned integer for the index of the end of the first match with a boolean case_insensitive flag

Source

fn pattern_last_start_index( &'a self, pattern: &str, case_insensitive: bool, ) -> Option<usize>

Yields an option with an unsigned integer for the index of the start of the last match with a boolean case_insensitive flag

Source

fn pattern_last_index( &'a self, pattern: &str, case_insensitive: bool, ) -> Option<usize>

with a boolean case_insensitive flag

Source

fn count_pattern(&'a self, pattern: &'a str, case_insensitive: bool) -> usize

Source

fn count_word(&'a self, word: &'a str, case_insensitive: bool) -> usize

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'a, T: AsRef<str>> PatternCapture<'a> for T

Implementation for any string-like type (&str, String, &String, Cow<str>, etc.)