Matches
This condition can be used on a source string. It returns true if the source string matches the configured regex pattern.
Available configuration keys:
-
regex: The regex pattern to match
-
negate: (optional) Whether to negate the 'matches' condition. Defaults to FALSE. You can also negate the 'matches' plugin by using 'not:matches' as the plugin id.
-
source: (optional) Property or array of properties on which to evaluate the condition. If not set, the condition will be evaluated on the source passed to the ::evaluate() method, typically the source of the process plugin that is using this condition.
The regex can be specified using parens syntax.
Examples
1. Set a boolean if a source string contains a number
process:
has_a_digit:
plugin: evaluate_condition
source: source_string
condition:
plugin: matches
regex: /\d+/
or equivalently using parens syntax:
process:
has_a_digit:
plugin: evaluate_condition
source: source_string
condition: matches(/\d+/)
2. Skip a row if a source string is not an exclamation
Because we should always be super excited about everything.
process:
_skip_calm_strings:
plugin: skip_on_condition
source: source_string
method: row
condition:
plugin: not:matches
regex: /!$/
message: 'We only want a string that ends with ! because we are always super excited'
or equivalently using parens syntax:
process:
_skip_calm_strings:
plugin: skip_on_condition
source: source_string
method: row
condition: not:matches(/!$/)
message: 'We only want a string that ends with ! because we are always super excited'
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion