Regular Expression Element
The regular expression (RegEx) element is used to test a string against a regular expression pattern.
The RegEx element is located in the Element Toolbox within Studio’s Embedded tab.
Properties
The following properties can be changed for the RegEx element:
Name
The name of the element.
Pattern
The regular expression pattern to match against. This pattern is based on the python re
module syntax. The following patterns are supported:
'.'
Dot, matches any character'^'
Start anchor, matches beginning of string'$'
End anchor, matches end of string'*'
Asterisk, match zero or more (greedy)'+'
Plus, match one or more (greedy)'?'
Question, match zero or one (non-greedy)'[abc]'
Character class, match if one of {‘a’, ‘b’, ‘c’}'[^abc]'
Inverted class, match if NOT one of {‘a’, ‘b’, ‘c’} – NOTE: this pattern is currently not working properly!-
'[a-zA-Z]'
Character ranges, the character set of the ranges { a-zA-Z } '\s'
Whitespace, \t \f \r \n \v and spaces'\S'
Non-whitespace'\w'
Alphanumeric, [a-zA-Z0-9_]'\W'
Non-alphanumeric'\d'
Digits, [0-9]'\D'
Non-digits
Triggers
The following triggers are available to execute events from within the RegEx element:
Triggered
Execute an event when the source element connected to the RegEx element triggers.
Pattern Matches
Regular expression pattern matches the input string.
Pattern Does Not Match
Regular expression pattern does not match the input string.
Abilities
The following abilities are available for the RegEx element when its source element triggers:
Trigger
Trigger the element(s) that follow the RegEx element.
Evaluate
Evaluate an input string against the pattern property.
Element Resources
Atmosphere includes a selection of resources for users of all levels that demonstrate using the RegEx element.
Demo Projects
To view the RegEx element used within a project, click the demo’s name to open the project in Atmosphere and see how the element is set up.
Name | Hardware | Description |
---|---|---|
RegEx Element ESP32 Demo | HUZZAH32 | The RegEx element is used within this demo project by giving an input a string via BLE using a button element and categorizing the string into non-alphanumeric, alphabet and numeral characters by checking if the string matches the regular expression pattern. |