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