API Docs - v5.0.2
Regex
find (Function)
These methods attempt to find the subsequence of the 'inputSequence' that matches the given '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 | A regular expression that is matched to a sequence in order to find the subsequence of the same. For example, \d\d(.*)WSO2. | STRING | No | No | |
input.sequence | The input sequence to be matched with the regular expression. For example, 21 products are produced by WSO2. | STRING | No | No | |
starting.index | The starting index of the input sequence from where the input sequence ismatched with 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 subsequence of the 'inputSequence' that matches the regex pattern, \d\d(.*)WSO2. It returns true as a subsequence 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 subsequence of the 'inputSequence' that matches the regex pattern, \d\d(.*)WSO2 . It returns 'false' as a subsequence does not exist.
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 subsequence of the 'inputSequence' that matches the regex pattern, \d\d(.*)WSO2 starting from index 30. It returns 'true' since a subsequence exists.
group (Function)
This method returns the input subsequence 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 | A regular expression. For example, \d\d(.*)WSO2. | STRING | No | No | |
input.sequence | The input sequence to be matched with the regular expression. For example, 21 products are produced by WSO2. | STRING | No | No | |
group.id | The given group id of the regex expression. For example, 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;
This function returns 'WSO2 employees', the input subsequence captured within the given groupID, 3 after grouping the 'inputSequence' according to the regex pattern, \d\d(.*)(WSO2.*).
lookingAt (Function)
This method attempts to match the 'inputSequence', from 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 | A regular expression. For example, \d\d(.*)WSO2. | STRING | No | No | |
input.sequence | The input sequence to be matched with the regular expression. For example, 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 the regex pattern, \d\d(.*)(WSO2.*) from the beginning. Since it matches, the function 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 it's a middleware company)
This method attempts to match the 'inputSequence' against the regex pattern, WSO2(.*)middleware(.*) from the beginning. Since it does not match, the function 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 | A regular expression. For example, \d\d(.*)WSO2. | STRING | No | No | |
input.sequence | The input sequence to be matched with the regular expression. For example, 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'.