pub trait PatternCapture<'a> {
Show 13 methods
// Required methods
fn pattern_captures(
&self,
pattern: &str,
case_insensitive: bool,
) -> Option<Captures<'_>>;
fn pattern_matches_as_vec(
&'a self,
pattern: &str,
case_insensitive: bool,
outer: bool,
) -> Vec<Match<'_>>;
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<'_>> { ... }
fn pattern_first_last_matches(
&'a self,
pattern: &str,
case_insensitive: bool,
) -> Option<(Match<'_>, Match<'_>)> { ... }
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§
Sourcefn pattern_captures(
&self,
pattern: &str,
case_insensitive: bool,
) -> Option<Captures<'_>>
fn pattern_captures( &self, pattern: &str, case_insensitive: bool, ) -> Option<Captures<'_>>
Yields an option with Regex::Captures as returned from re.captures, Accepts a boolean case_insensitive flag
Provided Methods§
Sourcefn pattern_matches_vec(
&'a self,
pattern: &str,
case_insensitive: bool,
) -> Vec<Match<'a>>
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
Sourcefn pattern_matches_outer(
&'a self,
pattern: &str,
case_insensitive: bool,
) -> Vec<Match<'a>>
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
Sourcefn pattern_last_match(
&'a self,
pattern: &str,
case_insensitive: bool,
) -> Option<Match<'_>>
fn pattern_last_match( &'a self, pattern: &str, case_insensitive: bool, ) -> Option<Match<'_>>
Yields an option with last match object if available with a boolean case_insensitive flag
Sourcefn pattern_first_last_matches(
&'a self,
pattern: &str,
case_insensitive: bool,
) -> Option<(Match<'_>, Match<'_>)>
fn pattern_first_last_matches( &'a self, pattern: &str, case_insensitive: bool, ) -> Option<(Match<'_>, Match<'_>)>
returns an option with a pair of match objects If there is only one match the match objects will have the same indices
Sourcefn pattern_first_index(
&'a self,
pattern: &str,
case_insensitive: bool,
) -> Option<usize>
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
Sourcefn pattern_first_end_index(
&'a self,
pattern: &str,
case_insensitive: bool,
) -> Option<usize>
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
Sourcefn pattern_last_start_index(
&'a self,
pattern: &str,
case_insensitive: bool,
) -> Option<usize>
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
Sourcefn pattern_last_index(
&'a self,
pattern: &str,
case_insensitive: bool,
) -> Option<usize>
fn pattern_last_index( &'a self, pattern: &str, case_insensitive: bool, ) -> Option<usize>
with a boolean case_insensitive flag
fn count_pattern(&'a self, pattern: &'a str, case_insensitive: bool) -> usize
fn count_word(&'a self, word: &'a str, case_insensitive: bool) -> usize
Implementations on Foreign Types§
Source§impl<'a> PatternCapture<'a> for str
Implementation for &str/String
impl<'a> PatternCapture<'a> for str
Implementation for &str/String
Source§fn pattern_captures(
&self,
pattern: &str,
case_insensitive: bool,
) -> Option<Captures<'_>>
fn pattern_captures( &self, pattern: &str, case_insensitive: bool, ) -> Option<Captures<'_>>
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>>
fn pattern_matches_as_vec( &'a self, pattern: &str, case_insensitive: bool, outer: bool, ) -> Vec<Match<'a>>
Returns vector of match objects. The outer options excludes inner match groups.
Source§fn pattern_first_match(
&'a self,
pattern: &str,
case_insensitive: bool,
) -> Option<Match<'a>>
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 Implemented here to shortcut the larger find_matches_within_haystack function