pub trait PatternReplacewhere
Self: Sized,{
// Required methods
fn pattern_replace_result(
&self,
pattern: &str,
replacement: &str,
case_insensitive: bool
) -> Result<Self, Error>
where Self: Sized;
fn pattern_replace_first_result(
&self,
pattern: &str,
replacement: &str,
case_insensitive: bool
) -> Result<Self, Error>
where Self: Sized;
fn pattern_replace(
&self,
pattern: &str,
replacement: &str,
case_insensitive: bool
) -> Self
where Self: Sized;
fn pattern_replace_first(
&self,
pattern: &str,
replacement: &str,
case_insensitive: bool
) -> Self
where Self: Sized;
// Provided methods
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 { ... }
fn pattern_replace_first_ci(&self, pattern: &str, replacement: &str) -> Self
where Self: Sized { ... }
fn pattern_replace_first_cs(&self, pattern: &str, replacement: &str) -> Self
where Self: Sized { ... }
}
Expand description
Core regular expression replacement methods
Required Methods§
sourcefn pattern_replace_result(
&self,
pattern: &str,
replacement: &str,
case_insensitive: bool
) -> Result<Self, Error>where
Self: Sized,
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 NB: If the regex doesn’t compile it will return an Error, otherwise in Ok result. If the regex fails, nothing will be replaced
sourcefn pattern_replace_first_result(
&self,
pattern: &str,
replacement: &str,
case_insensitive: bool
) -> Result<Self, Error>where
Self: Sized,
fn pattern_replace_first_result(
&self,
pattern: &str,
replacement: &str,
case_insensitive: bool
) -> Result<Self, Error>where
Self: Sized,
Replace only the first match of the pattern within a longer text with a boolean case_insensitive flag NB: If the regex doesn’t compile it will return an Error, otherwise in Ok result. If the regex fails, nothing will be replaced
sourcefn pattern_replace(
&self,
pattern: &str,
replacement: &str,
case_insensitive: bool
) -> Selfwhere
Self: Sized,
fn pattern_replace(
&self,
pattern: &str,
replacement: &str,
case_insensitive: bool
) -> Selfwhere
Self: Sized,
Replace all matches of the pattern within a longer text with a boolean case_insensitive flag Returns a copy of the same data type. If the regex fails, nothing will be replaced.
sourcefn pattern_replace_first(
&self,
pattern: &str,
replacement: &str,
case_insensitive: bool
) -> Selfwhere
Self: Sized,
fn pattern_replace_first(
&self,
pattern: &str,
replacement: &str,
case_insensitive: bool
) -> Selfwhere
Self: Sized,
Replace only the first match of the pattern within a longer text with a boolean case_insensitive flag Returns a copy of the same data type. If the regex fails, nothing will be replaced.
Provided Methods§
sourcefn pattern_replace_ci(&self, pattern: &str, replacement: &str) -> Selfwhere
Self: Sized,
fn pattern_replace_ci(&self, pattern: &str, replacement: &str) -> Selfwhere
Self: Sized,
Replace all matches of the pattern within a longer text in case-insensitive mode If the regex fails, nothing will be replaced
sourcefn pattern_replace_cs(&self, pattern: &str, replacement: &str) -> Selfwhere
Self: Sized,
fn pattern_replace_cs(&self, pattern: &str, replacement: &str) -> Selfwhere
Self: Sized,
Replace all matches of the pattern within a longer text in case-sensitive mode If the regex fails, nothing will be replaced
sourcefn pattern_replace_first_ci(&self, pattern: &str, replacement: &str) -> Selfwhere
Self: Sized,
fn pattern_replace_first_ci(&self, pattern: &str, replacement: &str) -> Selfwhere
Self: Sized,
Replace the first match only of the pattern within a longer text in case-insensitive mode If the regex fails, nothing will be replaced
sourcefn pattern_replace_first_cs(&self, pattern: &str, replacement: &str) -> Selfwhere
Self: Sized,
fn pattern_replace_first_cs(&self, pattern: &str, replacement: &str) -> Selfwhere
Self: Sized,
Replace the first match only of the pattern within a longer text in case-sensitive mode If the regex fails, nothing will be replaced
Object Safety§
Implementations on Foreign Types§
source§impl PatternReplace for String
impl PatternReplace for String
Core regex replacement methods for Strings
source§fn pattern_replace_result(
&self,
pattern: &str,
replacement: &str,
case_insensitive: bool
) -> Result<String, Error>
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_first_result(
&self,
pattern: &str,
replacement: &str,
case_insensitive: bool
) -> Result<String, Error>
fn pattern_replace_first_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§impl PatternReplace for Vec<String>
impl PatternReplace for Vec<String>
Implemented separately of arrays / vectors of strings to ensure the regex is only compiled once
source§fn pattern_replace_result(
&self,
pattern: &str,
replacement: &str,
case_insensitive: bool
) -> Result<Vec<String>, Error>
fn pattern_replace_result( &self, pattern: &str, replacement: &str, case_insensitive: bool ) -> Result<Vec<String>, Error>
Optional regex-enabled replace method that will return None if the regex fails
source§fn pattern_replace_first_result(
&self,
pattern: &str,
replacement: &str,
case_insensitive: bool
) -> Result<Vec<String>, Error>
fn pattern_replace_first_result( &self, pattern: &str, replacement: &str, case_insensitive: bool ) -> Result<Vec<String>, Error>
Optional regex-enabled replace method that will return None if the regex fails