Skip to main content

PatternMatch

Trait PatternMatch 

Source
pub trait PatternMatch {
    // Required method
    fn pattern_match_result(
        &self,
        pattern: &str,
        case_insensitive: bool,
    ) -> Result<bool, Error>;

    // Provided methods
    fn pattern_match(&self, pattern: &str, case_insensitive: bool) -> bool { ... }
    fn pattern_match_ci(&self, pattern: &str) -> bool { ... }
    fn pattern_match_cs(&self, pattern: &str) -> bool { ... }
}
Expand description

Core regular expression match methods

Required Methods§

Source

fn pattern_match_result( &self, pattern: &str, case_insensitive: bool, ) -> Result<bool, Error>

Apply a regular expression match on the current string If the regex doesn’t compile it will return an error

Provided Methods§

Source

fn pattern_match(&self, pattern: &str, case_insensitive: bool) -> bool

Apply a regular expression match on the current string with a boolean case_insensitive flag NB: If the regex doesn’t compile it will return false

Source

fn pattern_match_ci(&self, pattern: &str) -> bool

if the pattern does not match the source string or the regex fails

Source

fn pattern_match_cs(&self, pattern: &str) -> bool

Simple case-sensitive regex-compatible match method that will return false if the pattern does not match the source string or the regex fails

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T: AsRef<str>> PatternMatch for [T]

Boolean methods to match a pattern within an array of any string-like type

Source§

fn pattern_match_result( &self, pattern: &str, case_insensitive: bool, ) -> Result<bool, Error>

The regex is only compiled once across all elements, and only once ever per distinct (pattern, case_insensitive) pair across all calls, thanks to the shared regex cache.

Implementors§

Source§

impl<T: AsRef<str>> PatternMatch for T

Implement regular expression match methods for any string-like type (&str, String, &String, Cow<str>, etc.). The regex is compiled only once per distinct (pattern, case_insensitive) pair for the life of the process — see cached_regex — so calling this repeatedly with the same pattern, e.g. once per row of a large batch, never recompiles after the first call.