pub struct StringRegex {
pub input: String,
pub regex: String,
pub mismatch_error: Option<String>,
pub replace: Option<String>,
}
Expand description
The processor configuration.
Fields§
§input: String
The string that will be matched against the provided regex
, and
optionally replaced by the replace
pattern.
regex: String
The regular expression used to match the input
. See the regex crate
syntax documentation for more details.
mismatch_error: Option<String>
If the regex
pattern does not match the input
value, an error is
returned. By default, a generic mismatch error is returned.
You can set this value to have it be returned as the error instead.
replace: Option<String>
Optionally use the regex
pattern and the input
to construct a
replacement string to return as this processors output.
You can use variables such as $1
and $2
to match against the
patterns in the regex.
Trait Implementations§
Source§impl Clone for StringRegex
impl Clone for StringRegex
Source§fn clone(&self) -> StringRegex
fn clone(&self) -> StringRegex
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for StringRegex
impl Debug for StringRegex
Source§impl<'de> Deserialize<'de> for StringRegex
impl<'de> Deserialize<'de> for StringRegex
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 StringRegex
impl PartialEq for StringRegex
Source§impl<'a> Processor<'a> for StringRegex
impl<'a> Processor<'a> for StringRegex
Source§fn validate(&self) -> Result<(), Self::Error>
fn validate(&self) -> Result<(), Self::Error>
Validate that the provided regex
pattern is valid.
§Errors
If the regex syntax is invalid, the Error::Syntax
error variant is
returned.
If the regex pattern is too big (highly unlikely), the
Error::CompiledTooBig
error variant is returned.
Both variants wrap the original Regex crate errors.
Source§fn run(&self, _context: &Context) -> Result<Option<Self::Output>, Self::Error>
fn run(&self, _context: &Context) -> Result<Option<Self::Output>, Self::Error>
Do a regex match (and replace), based on the processor configuration.
§Output
If replace
is set to None
, the output of the processor will be
Ok(None)
if no error occurred.
If replace
is set to Some
, then Some
is returned, matching the
final replaced output value in Processor::Output
.
§Errors
If the regex
pattern does not match the input
input, the
Error::Match
error variant is returned. If mismatch_error
is
set, the error will contain the provided message. If not, a default
message is provided.
If the regex pattern is invalid, the same errors are returned as
validate
.