Unknown macro: {next_previous_links}
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

This extension provides basic RegEx execution capabilities to Siddhi. Following are the functions of the RegEx extension.

Find function

Syntax<bool> regex:find (<string> regex , <string> inputSequence )
Extension TypeFunction
DescriptionThis method attempts to find the next sub-sequence of the inputSequence that matches the regex pattern. It returns true if such a sub sequence exists, or returns false otherwise.
Examples
  • find("\d\d(.*)WSO2", "21 products are produced by WSO2 currently") returns true.
  • find("\d\d(.*)WSO2", "21 products are produced currently") returns false.
Syntax<bool> regex:find (<string> regex , <string> inputSequence, <int> startingIndex )
Extension TypeFunction
DescriptionThis method attempts to find the next sub-sequence of the inputSequence that matches the regex pattern starting from given index (i.e. startingIndex). It returns true if such a sub sequence exists, or returns false otherwise.
Examples
  • find("\d\d(.*)WSO2", "21 products are produced within 10 years by WSO2 currently by WSO2 employees",  30) returns true.
  • find("\d\d(.*)WSO2", "21 products are produced within 10 years by WSO2 currently by WSO2 employees", 35) returns false.


Group function

Syntax<string> regex:group (<string> regex , <string> inputSequence , <int>  groupId )
Extension TypeFunction
DescriptionReturns the input sub-sequence captured by the given group during the previous match operation. Returns null if no sub-sequence was found during the previous match operation. For more information about the match operation, see matches.
Example group("(\d\d)(.*)(WSO2.*)", "21 products are produced within 10 years by WSO2 currently by WSO2 employees", 3) returns "WSO2 employees".


Looking At function

Syntax<string> regex:lookingAt (<string> regex , <string> inputSequence )
Extension TypeFunction
DescriptionThis method attempts to match the inputSequence against the regex pattern starting at the beginning.
Examples
  • lookingAt("\d\d(.*)WSO2", "21 products are produced by WSO2 currently in Sri Lanka") returns true.
  • lookingAt("WSO2(.*)middleware(.*)", "sample test string and WSO2 is situated in trace and its a middleware company") returns false.


Matches function

Syntax<string> regex:matches (<string> regex , <string> inputSequence )
Extension TypeFunction
DescriptionThis method attempts to match the entire inputSequence against the regex pattern.
Examples
  • matches("WSO2(.*)middleware(.*)", "WSO2 is situated in trace and its a middleware company") returns true.
  • matches("WSO2(.*)middleware", "WSO2 is situated in trace and its a middleware company") returns false.
  • No labels