Match against multiple regex patterns.
# Match a/b/c/d
- value: (@ flow.foo )
match:
(?P<a_group>a+):
say: A (@ flow.groups.a_group )
b.b:
jump: b
(cc)+:
jump: c
default:
jump: d
Each condition in the match
field must contain a valid action field,
meaning the field takes an action spec which maps to the ActionComponentSpec
Python class. This allows you to execute any component, but you will mostly
use one of the flow control components.
Also, Meya uses the Python regular expression syntax for all regex patterns.
Match groups
If your regex pattern defines any match groups, then these match groups
will be available in flow scope under (@ flow.groups )
.
Element details
type: meya.flow.component.match
class: MatchComponent
path: /meya/flow/component/match.py
signature: match
Fields
field | description | required | signature | default | type |
---|---|---|---|---|---|
spec | Override the original spec for this element. | ○ | ○ | null | Spec |
context | Send context data with this component's event. | ○ | ○ | {} | dict |
sensitive | Mark this component's event as sensitive. This will encrypt the event if the Sensitive Data integration has been enabled. | ○ | ○ | false | bool |
triggers | Activate these dynamic triggers when the component runs. Check the component triggers guide for more info. | ○ | ○ | [] | list |
value | Sets the value that needs to be matched against the multiple regex patterns. If value is not defined, then the component will try use the value set in (@ flow.result ) , if no value could be found then an error is raised. | ○ | ○ | null | typing.Any |
ignorecase | Ignore the case of the value field. | ○ | ○ | null | bool |
match | Contains a set of regex patterns and actions that will be evaluated against the value defined in the value field. The action is a component reference that is called when the value matches the regex pattern. | ◉ | ◉ | dict | |
default | This the default action should the value not match any of the regex patterns. | ◉ | ○ | ActionComponentSpec | |
Usage reference
Basic
triggers:
- keyword: meya.flow.component.match
steps:
- match:
STRING: COMPONENT
default: COMPONENT
Full
triggers:
- keyword: meya.flow.component.match
steps:
- spec:
type: STRING
data:
STRING: ANY
timeout: 123
trigger_when: ANY
context:
STRING: ANY
sensitive: false
triggers:
- type: STRING
data:
STRING: ANY
timeout: 123
trigger_when: ANY
value: ANY
ignorecase: false
match:
STRING: COMPONENT
default: COMPONENT