pub trait PatternReplace {
    // Required methods
    fn pattern_replace(
        &self,
        pattern: &str,
        replacement: &str,
        case_insensitive: bool
    ) -> Self
       where Self: Sized;
    fn pattern_replace_result(
        &self,
        pattern: &str,
        replacement: &str,
        case_insensitive: bool
    ) -> Result<Self, Error>
       where Self: Sized;
    fn pattern_replace_ci(&self, pattern: &str, replacement: &str) -> Self
       where Self: Sized;
    fn pattern_replace_cs(&self, pattern: &str, replacement: &str) -> Self
       where Self: Sized;
}
Expand description

Core regular expression replacement methods

Required Methods§

source

fn pattern_replace( &self, pattern: &str, replacement: &str, case_insensitive: bool ) -> Self
where Self: Sized,

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 an Error, otherwise in Ok result.

source

fn pattern_replace_result( &self, pattern: &str, replacement: &str, case_insensitive: bool ) -> Result<Self, Error>
where Self: Sized,

Replace all matches of the pattern within a longer text with a boolean case_insensitive flag If the regex fails, nothing will be replaced

source

fn pattern_replace_ci(&self, pattern: &str, replacement: &str) -> Self
where Self: Sized,

Replace all matches of the pattern within a longer text in case-insensitive mode If the regex fails, nothing will be replaced

source

fn pattern_replace_cs(&self, pattern: &str, replacement: &str) -> Self
where Self: Sized,

Replace all matches of the pattern within a longer text in case-sensitive mode If the regex fails, nothing will be replaced

Implementations on Foreign Types§

source§

impl PatternReplace for String

source§

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

Regex-enabled replace method that will return an OK String result if successful and an error if the regex fails

source§

fn pattern_replace( &self, pattern: &str, replacement: &str, case_insensitive: bool ) -> String

Simple regex-enabled replace method that will return the same string if the regex fails

source§

fn pattern_replace_ci(&self, pattern: &str, replacement: &str) -> String

Simple case-insensitive regex-enabled replace method that will return the same string if the regex fails

source§

fn pattern_replace_cs(&self, pattern: &str, replacement: &str) -> String

Simple case-sensitive regex-enabled replace method that will return the same string if the regex fails

source§

impl PatternReplace for Vec<String>

source§

fn pattern_replace_result( &self, pattern: &str, replacement: &str, case_insensitive: bool ) -> Result<Vec<String>, Error>

Optional regex-enabledd replace method that will return None if the regex fails

source§

fn pattern_replace( &self, pattern: &str, replacement: &str, case_insensitive: bool ) -> Vec<String>

Simple regex-enabledd replace method that will return the same string if the regex fails

source§

fn pattern_replace_ci(&self, pattern: &str, replacement: &str) -> Vec<String>

Simple case-insensitive regex-enabled replace method that will return the same string if the regex fails

source§

fn pattern_replace_cs(&self, pattern: &str, replacement: &str) -> Vec<String>

Simple case-sensitive regex-enabled replace method that will return the same string if the regex fails

Implementors§