API Docs - v4.0.13
Regex
find (Function)
These methods attempts to find the next sub-sequence of the 'inputSequence' that matches the 'regex' pattern.
Syntax
<BOOL> regex:find(<STRING> regex, <STRING> input.sequence, <INT> starting.index)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
regex | regular expression. eg: \d\d(.*)WSO2. | STRING | No | No | |
input.sequence | input sequence to be matched with the regular expression eg: 21 products are produced by WSO2. | STRING | No | No | |
starting.index | starting index of the input sequence to start matching the given regex pattern eg: 1, 2. | INT | No | No |
Examples EXAMPLE 1
define stream inputStream (inputSequence string, price long, regex string);
from inputStream select inputSequence , regex:find(\d\d(.*)WSO2, 21 products are produced by WSO2 currently) as aboutWSO2 insert into outputStream;
This method attempts to find the next sub-sequence of the inputSequence that matches \d\d(.*)WSO2 regex pattern. It returns true as the sub sequence exists.
EXAMPLE 2
define stream inputStream (inputSequence string, price long, regex string);
from inputStream select inputSequence , regex:find(\d\d(.*)WSO2, 21 products are produced currently) as aboutWSO2 insert into outputStream;
This method attempts to find the next sub-sequence of the inputSequence that matches \d\d(.*)WSO2 regex pattern. It returns false as the sub sequence does not exists.
EXAMPLE 3
define stream inputStream (inputSequence string, price long, regex string);
from inputStream select inputSequence , regex:find(\d\d(.*)WSO2, 21 products are produced within 10 years by WSO2 currently by WSO2 employees, 30) as aboutWSO2 insert into outputStream;
This method attempts to find the next sub-sequence of the inputSequence that matches \d\d(.*)WSO2 regex pattern starting from index 30. It returns true since such a sub sequence exists.
group (Function)
This method returns the input sub-sequence captured by the given group during the previous match operation.
Syntax
<STRING> regex:group(<STRING> regex, <STRING> input.sequence, <INT> group.id)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
regex | regular expression. eg: \d\d(.*)WSO2. | STRING | No | No | |
input.sequence | input sequence to be matched with the regular expression eg: 21 products are produced by WSO2. | STRING | No | No | |
group.id | the given group id of the regex expression eg: 0, 1, 2, etc. | INT | No | No |
Examples EXAMPLE 1
define stream inputStream (inputSequence string, price long, regex string, group int);
from inputStream select inputSequence, regex:group(\d\d(.*)(WSO2.*), 21 products are produced within 10 years by WSO2 currently by WSO2 employees, 3)
insert into outputStream;
Returns 'WSO2 employees', input sub-sequence captured by the given groupID, 3 during the previous match operation.
lookingAt (Function)
This method attempts to match the 'inputSequence', starting at the beginning, against the 'regex' pattern.
Syntax
<BOOL> regex:lookingAt(<STRING> regex, <STRING> input.sequence)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
regex | regular expression. eg: \d\d(.*)WSO2. | STRING | No | No | |
input.sequence | input sequence to be matched with the regular expression eg: 21 products are produced by WSO2. | STRING | No | No |
Examples EXAMPLE 1
define stream inputStream (inputSequence string, price long, regex string, group int);
from inputStream select inputSequence, regex:lookingAt(\d\d(.*)(WSO2.*), 21 products are produced by WSO2 currently in Sri Lanka)
This method attempts to match the inputSequence against \d\d(.*)(WSO2.*) regex pattern starting at the beginning. Since it matches, returns true.
EXAMPLE 2
define stream inputStream (inputSequence string, price long, regex string, group int);
from inputStream select inputSequence, regex:lookingAt(WSO2(.*)middleware(.*), sample test string and WSO2 is situated in trace and its a middleware company)
This method attempts to match the inputSequence against WSO2(.*)middleware(.*) regex pattern starting at the beginning. Since it does not match, returns false.
matches (Function)
This method attempts to match the entire 'inputSequence' against the 'regex' pattern.
Syntax
<BOOL> regex:matches(<STRING> regex, <STRING> input.sequence)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
regex | regular expression. eg: \d\d(.*)WSO2. | STRING | No | No | |
input.sequence | input sequence to be matched with the regular expression eg: 21 products are produced by WSO2. | STRING | No | No |
Examples EXAMPLE 1
define stream inputStream (inputSequence string, price long, regex string, group int);
from inputStream select inputSequence, regex:matches(WSO2(.*)middleware(.*), WSO2 is situated in trace and its a middleware company)
This method attempts to match the entire inputSequence against WSO2(.*)middleware(.*) regex pattern. Since it matches, it returns true.
EXAMPLE 2
define stream inputStream (inputSequence string, price long, regex string, group int);
from inputStream select inputSequence, regex:matches(WSO2(.*)middleware, WSO2 is situated in trace and its a middleware company)
This method attempts to match the entire inputSequence against WSO2(.*)middleware regex pattern. Since it does not match, it returns false.