pub struct RegexReplacement {
pub type: TypeTrue,
pub regex: String,
pub options: Option<Vec<RegexOption>>,
pub value: String,
}Fields§
§type: TypeTrueThis is the regex replacement type. You can use this to replace a word or phrase that matches a pattern. Usage: - Replace all numbers with "some number": { type: ‘regex’, regex: ‘\\d+’, value: ‘some number’ } - Replace email addresses with "[EMAIL]": { type: ‘regex’, regex: ‘\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b’, value: ‘[EMAIL]’ } - Replace phone numbers with a formatted version: { type: ‘regex’, regex: ‘(\\d{3})(\\d{3})(\\d{4})’, value: ‘($1) $2-$3’ } - Replace all instances of "color" or "colour" with "hue": { type: ‘regex’, regex: ‘colou?r’, value: ‘hue’ } - Capitalize the first letter of every sentence: { type: ‘regex’, regex: ‘(?<=\\. |^)[a-z]’, value: (match) => match.toUpperCase() }
regex: StringThis is the regex pattern to replace. Note: - This works by using the string.replace method in Node.JS. Eg. \"hello there\".replace(/hello/g, \"hi\") will return \"hi there\". Hot tip: - In JavaScript, escape \\ when sending the regex pattern. Eg. \"hello\\sthere\" will be sent over the wire as \"hellosthere\". Send \"hello\\\\sthere\" instead.
options: Option<Vec<RegexOption>>These are the options for the regex replacement. Defaults to all disabled. @default []
value: StringThis is the value that will replace the match.
Implementations§
Trait Implementations§
Source§impl Clone for RegexReplacement
impl Clone for RegexReplacement
Source§fn clone(&self) -> RegexReplacement
fn clone(&self) -> RegexReplacement
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RegexReplacement
impl Debug for RegexReplacement
Source§impl Default for RegexReplacement
impl Default for RegexReplacement
Source§fn default() -> RegexReplacement
fn default() -> RegexReplacement
Source§impl<'de> Deserialize<'de> for RegexReplacement
impl<'de> Deserialize<'de> for RegexReplacement
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for RegexReplacement
impl PartialEq for RegexReplacement
Source§fn eq(&self, other: &RegexReplacement) -> bool
fn eq(&self, other: &RegexReplacement) -> bool
self and other values to be equal, and is used by ==.