Regex Matching
This demonstrates event cleansing using regex expressions.
Regex operations can be performed using Siddhi Execution Regex extension.
define stream SweetProductionStream (name string, amount int);
@info(name='ProcessSweetProductionStream')
from SweetProductionStream
select name,
regex:matches('chocolate(.*)', name) as isAChocolateProduct,
regex:group('.*\s(.*)', name, 1) as sweetType
insert into ChocolateProductStream;
|
Defines |
|
|
|
Matches if |
|
Captures the |
|
Input
Below event is sent to SweetProductionStream
,
['chocolate cake'
, 34
]
Output
After processing, the event arriving at ChocolateProductStream
will be as follows:
['chocolate cake'
, true
, 'cake'
]