|
| 1 | +# API Docs - v5.0.3 |
| 2 | + |
| 3 | +## Regex |
| 4 | + |
| 5 | +### find *<a target="_blank" href="http://siddhi.io/documentation/siddhi-5.x/query-guide-5.x/#function">(Function)</a>* |
| 6 | + |
| 7 | +<p style="word-wrap: break-word">These methods attempt to find the subsequence of the 'inputSequence' that matches the given 'regex' pattern.</p> |
| 8 | + |
| 9 | +<span id="syntax" class="md-typeset" style="display: block; font-weight: bold;">Syntax</span> |
| 10 | +``` |
| 11 | +<BOOL> regex:find(<STRING> regex, <STRING> input.sequence, <INT> starting.index) |
| 12 | +``` |
| 13 | + |
| 14 | +<span id="query-parameters" class="md-typeset" style="display: block; color: rgba(0, 0, 0, 0.54); font-size: 12.8px; font-weight: bold;">QUERY PARAMETERS</span> |
| 15 | +<table> |
| 16 | + <tr> |
| 17 | + <th>Name</th> |
| 18 | + <th style="min-width: 20em">Description</th> |
| 19 | + <th>Default Value</th> |
| 20 | + <th>Possible Data Types</th> |
| 21 | + <th>Optional</th> |
| 22 | + <th>Dynamic</th> |
| 23 | + </tr> |
| 24 | + <tr> |
| 25 | + <td style="vertical-align: top">regex</td> |
| 26 | + <td style="vertical-align: top; word-wrap: break-word">A regular expression that is matched to a sequence in order to find the subsequence of the same. For example, \d\d(.*)WSO2.</td> |
| 27 | + <td style="vertical-align: top"></td> |
| 28 | + <td style="vertical-align: top">STRING</td> |
| 29 | + <td style="vertical-align: top">No</td> |
| 30 | + <td style="vertical-align: top">No</td> |
| 31 | + </tr> |
| 32 | + <tr> |
| 33 | + <td style="vertical-align: top">input.sequence</td> |
| 34 | + <td style="vertical-align: top; word-wrap: break-word">The input sequence to be matched with the regular expression. For example, 21 products are produced by WSO2.</td> |
| 35 | + <td style="vertical-align: top"></td> |
| 36 | + <td style="vertical-align: top">STRING</td> |
| 37 | + <td style="vertical-align: top">No</td> |
| 38 | + <td style="vertical-align: top">No</td> |
| 39 | + </tr> |
| 40 | + <tr> |
| 41 | + <td style="vertical-align: top">starting.index</td> |
| 42 | + <td style="vertical-align: top; word-wrap: break-word">The starting index of the input sequence from where the input sequence ismatched with the given regex pattern. eg: 1, 2.</td> |
| 43 | + <td style="vertical-align: top"></td> |
| 44 | + <td style="vertical-align: top">INT</td> |
| 45 | + <td style="vertical-align: top">No</td> |
| 46 | + <td style="vertical-align: top">No</td> |
| 47 | + </tr> |
| 48 | +</table> |
| 49 | + |
| 50 | +<span id="examples" class="md-typeset" style="display: block; font-weight: bold;">Examples</span> |
| 51 | +<span id="example-1" class="md-typeset" style="display: block; color: rgba(0, 0, 0, 0.54); font-size: 12.8px; font-weight: bold;">EXAMPLE 1</span> |
| 52 | +``` |
| 53 | +define stream InputStream (inputSequence string, price long, regex string); |
| 54 | +
|
| 55 | +from InputStream select inputSequence , regex:find(\d\d(.*)WSO2, 21 products are produced by WSO2 currently) as aboutWSO2 insert into OutputStream; |
| 56 | +
|
| 57 | +``` |
| 58 | +<p style="word-wrap: break-word">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.</p> |
| 59 | + |
| 60 | +<span id="example-2" class="md-typeset" style="display: block; color: rgba(0, 0, 0, 0.54); font-size: 12.8px; font-weight: bold;">EXAMPLE 2</span> |
| 61 | +``` |
| 62 | +define stream InputStream (inputSequence string, price long, regex string); |
| 63 | +
|
| 64 | +from InputStream select inputSequence , regex:find(\d\d(.*)WSO2, 21 products are produced currently) as aboutWSO2 insert into OutputStream; |
| 65 | +
|
| 66 | +``` |
| 67 | +<p style="word-wrap: break-word">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.</p> |
| 68 | + |
| 69 | +<span id="example-3" class="md-typeset" style="display: block; color: rgba(0, 0, 0, 0.54); font-size: 12.8px; font-weight: bold;">EXAMPLE 3</span> |
| 70 | +``` |
| 71 | +define stream InputStream (inputSequence string, price long, regex string); |
| 72 | +
|
| 73 | +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; |
| 74 | +
|
| 75 | +``` |
| 76 | +<p style="word-wrap: break-word">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.</p> |
| 77 | + |
| 78 | +### group *<a target="_blank" href="http://siddhi.io/documentation/siddhi-5.x/query-guide-5.x/#function">(Function)</a>* |
| 79 | + |
| 80 | +<p style="word-wrap: break-word">This method returns the input subsequence captured by the given group during the previous match operation.</p> |
| 81 | + |
| 82 | +<span id="syntax" class="md-typeset" style="display: block; font-weight: bold;">Syntax</span> |
| 83 | +``` |
| 84 | +<STRING> regex:group(<STRING> regex, <STRING> input.sequence, <INT> group.id) |
| 85 | +``` |
| 86 | + |
| 87 | +<span id="query-parameters" class="md-typeset" style="display: block; color: rgba(0, 0, 0, 0.54); font-size: 12.8px; font-weight: bold;">QUERY PARAMETERS</span> |
| 88 | +<table> |
| 89 | + <tr> |
| 90 | + <th>Name</th> |
| 91 | + <th style="min-width: 20em">Description</th> |
| 92 | + <th>Default Value</th> |
| 93 | + <th>Possible Data Types</th> |
| 94 | + <th>Optional</th> |
| 95 | + <th>Dynamic</th> |
| 96 | + </tr> |
| 97 | + <tr> |
| 98 | + <td style="vertical-align: top">regex</td> |
| 99 | + <td style="vertical-align: top; word-wrap: break-word">A regular expression. For example, \d\d(.*)WSO2.</td> |
| 100 | + <td style="vertical-align: top"></td> |
| 101 | + <td style="vertical-align: top">STRING</td> |
| 102 | + <td style="vertical-align: top">No</td> |
| 103 | + <td style="vertical-align: top">No</td> |
| 104 | + </tr> |
| 105 | + <tr> |
| 106 | + <td style="vertical-align: top">input.sequence</td> |
| 107 | + <td style="vertical-align: top; word-wrap: break-word">The input sequence to be matched with the regular expression. For example, 21 products are produced by WSO2.</td> |
| 108 | + <td style="vertical-align: top"></td> |
| 109 | + <td style="vertical-align: top">STRING</td> |
| 110 | + <td style="vertical-align: top">No</td> |
| 111 | + <td style="vertical-align: top">No</td> |
| 112 | + </tr> |
| 113 | + <tr> |
| 114 | + <td style="vertical-align: top">group.id</td> |
| 115 | + <td style="vertical-align: top; word-wrap: break-word">The given group id of the regex expression. For example, 0, 1, 2, etc.</td> |
| 116 | + <td style="vertical-align: top"></td> |
| 117 | + <td style="vertical-align: top">INT</td> |
| 118 | + <td style="vertical-align: top">No</td> |
| 119 | + <td style="vertical-align: top">No</td> |
| 120 | + </tr> |
| 121 | +</table> |
| 122 | + |
| 123 | +<span id="examples" class="md-typeset" style="display: block; font-weight: bold;">Examples</span> |
| 124 | +<span id="example-1" class="md-typeset" style="display: block; color: rgba(0, 0, 0, 0.54); font-size: 12.8px; font-weight: bold;">EXAMPLE 1</span> |
| 125 | +``` |
| 126 | +define stream InputStream (inputSequence string, price long, regex string, group int); |
| 127 | +
|
| 128 | +from InputStream select inputSequence, regex:group(\d\d(.*)(WSO2.*), 21 products are produced within 10 years by WSO2 currently by WSO2 employees, 3) |
| 129 | + insert into OutputStream; |
| 130 | +``` |
| 131 | +<p style="word-wrap: break-word">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.*). </p> |
| 132 | + |
| 133 | +### lookingAt *<a target="_blank" href="http://siddhi.io/documentation/siddhi-5.x/query-guide-5.x/#function">(Function)</a>* |
| 134 | + |
| 135 | +<p style="word-wrap: break-word">This method attempts to match the 'inputSequence', from the beginning, against the 'regex' pattern.</p> |
| 136 | + |
| 137 | +<span id="syntax" class="md-typeset" style="display: block; font-weight: bold;">Syntax</span> |
| 138 | +``` |
| 139 | +<BOOL> regex:lookingAt(<STRING> regex, <STRING> input.sequence) |
| 140 | +``` |
| 141 | + |
| 142 | +<span id="query-parameters" class="md-typeset" style="display: block; color: rgba(0, 0, 0, 0.54); font-size: 12.8px; font-weight: bold;">QUERY PARAMETERS</span> |
| 143 | +<table> |
| 144 | + <tr> |
| 145 | + <th>Name</th> |
| 146 | + <th style="min-width: 20em">Description</th> |
| 147 | + <th>Default Value</th> |
| 148 | + <th>Possible Data Types</th> |
| 149 | + <th>Optional</th> |
| 150 | + <th>Dynamic</th> |
| 151 | + </tr> |
| 152 | + <tr> |
| 153 | + <td style="vertical-align: top">regex</td> |
| 154 | + <td style="vertical-align: top; word-wrap: break-word">A regular expression. For example, \d\d(.*)WSO2.</td> |
| 155 | + <td style="vertical-align: top"></td> |
| 156 | + <td style="vertical-align: top">STRING</td> |
| 157 | + <td style="vertical-align: top">No</td> |
| 158 | + <td style="vertical-align: top">No</td> |
| 159 | + </tr> |
| 160 | + <tr> |
| 161 | + <td style="vertical-align: top">input.sequence</td> |
| 162 | + <td style="vertical-align: top; word-wrap: break-word">The input sequence to be matched with the regular expression. For example, 21 products are produced by WSO2.</td> |
| 163 | + <td style="vertical-align: top"></td> |
| 164 | + <td style="vertical-align: top">STRING</td> |
| 165 | + <td style="vertical-align: top">No</td> |
| 166 | + <td style="vertical-align: top">No</td> |
| 167 | + </tr> |
| 168 | +</table> |
| 169 | + |
| 170 | +<span id="examples" class="md-typeset" style="display: block; font-weight: bold;">Examples</span> |
| 171 | +<span id="example-1" class="md-typeset" style="display: block; color: rgba(0, 0, 0, 0.54); font-size: 12.8px; font-weight: bold;">EXAMPLE 1</span> |
| 172 | +``` |
| 173 | +define stream InputStream (inputSequence string, price long, regex string, group int); |
| 174 | +
|
| 175 | +from InputStream select inputSequence, regex:lookingAt(\d\d(.*)(WSO2.*), 21 products are produced by WSO2 currently in Sri Lanka) |
| 176 | +``` |
| 177 | +<p style="word-wrap: break-word">This method attempts to match the 'inputSequence' against the regex pattern, \d\d(.*)(WSO2.*) from the beginning. Since it matches, the function returns 'true'.</p> |
| 178 | + |
| 179 | +<span id="example-2" class="md-typeset" style="display: block; color: rgba(0, 0, 0, 0.54); font-size: 12.8px; font-weight: bold;">EXAMPLE 2</span> |
| 180 | +``` |
| 181 | +define stream InputStream (inputSequence string, price long, regex string, group int); |
| 182 | +
|
| 183 | +from InputStream select inputSequence, regex:lookingAt(WSO2(.*)middleware(.*), sample test string and WSO2 is situated in trace and it's a middleware company) |
| 184 | +``` |
| 185 | +<p style="word-wrap: break-word">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.</p> |
| 186 | + |
| 187 | +### matches *<a target="_blank" href="http://siddhi.io/documentation/siddhi-5.x/query-guide-5.x/#function">(Function)</a>* |
| 188 | + |
| 189 | +<p style="word-wrap: break-word">This method attempts to match the entire 'inputSequence' against the 'regex' pattern.</p> |
| 190 | + |
| 191 | +<span id="syntax" class="md-typeset" style="display: block; font-weight: bold;">Syntax</span> |
| 192 | +``` |
| 193 | +<BOOL> regex:matches(<STRING> regex, <STRING> input.sequence) |
| 194 | +``` |
| 195 | + |
| 196 | +<span id="query-parameters" class="md-typeset" style="display: block; color: rgba(0, 0, 0, 0.54); font-size: 12.8px; font-weight: bold;">QUERY PARAMETERS</span> |
| 197 | +<table> |
| 198 | + <tr> |
| 199 | + <th>Name</th> |
| 200 | + <th style="min-width: 20em">Description</th> |
| 201 | + <th>Default Value</th> |
| 202 | + <th>Possible Data Types</th> |
| 203 | + <th>Optional</th> |
| 204 | + <th>Dynamic</th> |
| 205 | + </tr> |
| 206 | + <tr> |
| 207 | + <td style="vertical-align: top">regex</td> |
| 208 | + <td style="vertical-align: top; word-wrap: break-word">A regular expression. For example, \d\d(.*)WSO2.</td> |
| 209 | + <td style="vertical-align: top"></td> |
| 210 | + <td style="vertical-align: top">STRING</td> |
| 211 | + <td style="vertical-align: top">No</td> |
| 212 | + <td style="vertical-align: top">No</td> |
| 213 | + </tr> |
| 214 | + <tr> |
| 215 | + <td style="vertical-align: top">input.sequence</td> |
| 216 | + <td style="vertical-align: top; word-wrap: break-word">The input sequence to be matched with the regular expression. For example, 21 products are produced by WSO2.</td> |
| 217 | + <td style="vertical-align: top"></td> |
| 218 | + <td style="vertical-align: top">STRING</td> |
| 219 | + <td style="vertical-align: top">No</td> |
| 220 | + <td style="vertical-align: top">No</td> |
| 221 | + </tr> |
| 222 | +</table> |
| 223 | + |
| 224 | +<span id="examples" class="md-typeset" style="display: block; font-weight: bold;">Examples</span> |
| 225 | +<span id="example-1" class="md-typeset" style="display: block; color: rgba(0, 0, 0, 0.54); font-size: 12.8px; font-weight: bold;">EXAMPLE 1</span> |
| 226 | +``` |
| 227 | +define stream InputStream (inputSequence string, price long, regex string, group int); |
| 228 | +
|
| 229 | +from InputStream select inputSequence, regex:matches(WSO2(.*)middleware(.*), WSO2 is situated in trace and its a middleware company) |
| 230 | +``` |
| 231 | +<p style="word-wrap: break-word">This method attempts to match the entire 'inputSequence' against WSO2(.*)middleware(.*) regex pattern. Since it matches, it returns 'true'.</p> |
| 232 | + |
| 233 | +<span id="example-2" class="md-typeset" style="display: block; color: rgba(0, 0, 0, 0.54); font-size: 12.8px; font-weight: bold;">EXAMPLE 2</span> |
| 234 | +``` |
| 235 | +define stream inputStream (inputSequence string, price long, regex string, group int); |
| 236 | +
|
| 237 | +from inputStream select inputSequence, regex:matches(WSO2(.*)middleware, WSO2 is situated in trace and its a middleware company) |
| 238 | +``` |
| 239 | +<p style="word-wrap: break-word">This method attempts to match the entire 'inputSequence' against WSO2(.*)middleware regex pattern. Since it does not match, it returns 'false'.</p> |
| 240 | + |
0 commit comments