Skip to content

Commit 69698ae

Browse files
authored
Merge pull request #42 from suhothayan/master
Improve API Docs
2 parents 4933980 + bdf6e1e commit 69698ae

File tree

2 files changed

+82
-136
lines changed

2 files changed

+82
-136
lines changed

docs/api/5.0.3.md

Lines changed: 41 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# API Docs - v5.0.3
22

3-
## Regex
4-
5-
### find *<a target="_blank" href="https://siddhi.io/en/v5.0/docs/query-guide/#function">(Function)</a>*
3+
!!! Info "Tested Siddhi Core version: *<a target="_blank" href="http://siddhi.io/en/v5.0/docs/query-guide/">5.0.0</a>*"
4+
It could also support other Siddhi Core minor versions.
65

7-
<p style="word-wrap: break-word">These methods attempt to find the subsequence of the 'inputSequence' that matches the given 'regex' pattern.</p>
6+
## Regex
87

8+
### find *<a target="_blank" href="http://siddhi.io/en/v5.0/docs/query-guide/#function">(Function)</a>*
9+
<p style="word-wrap: break-word">Finds the subsequence that matches the given regex pattern.</p>
910
<span id="syntax" class="md-typeset" style="display: block; font-weight: bold;">Syntax</span>
11+
1012
```
1113
<BOOL> regex:find(<STRING> regex, <STRING> input.sequence, <INT> starting.index)
1214
```
@@ -23,63 +25,47 @@
2325
</tr>
2426
<tr>
2527
<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>
28+
<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, <code>\d\d(.*)WSO2</code>.</td>
2729
<td style="vertical-align: top"></td>
2830
<td style="vertical-align: top">STRING</td>
2931
<td style="vertical-align: top">No</td>
3032
<td style="vertical-align: top">No</td>
3133
</tr>
3234
<tr>
3335
<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>
36+
<td style="vertical-align: top; word-wrap: break-word">The input sequence to be matched with the regular expression. For example, <code>21 products are produced by WSO2</code>.</td>
3537
<td style="vertical-align: top"></td>
3638
<td style="vertical-align: top">STRING</td>
3739
<td style="vertical-align: top">No</td>
3840
<td style="vertical-align: top">No</td>
3941
</tr>
4042
<tr>
4143
<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; word-wrap: break-word">The starting index of the input sequence from where the input sequence ismatched with the given regex pattern.For example, <code>10</code>.</td>
45+
<td style="vertical-align: top">0</td>
4446
<td style="vertical-align: top">INT</td>
45-
<td style="vertical-align: top">No</td>
47+
<td style="vertical-align: top">Yes</td>
4648
<td style="vertical-align: top">No</td>
4749
</tr>
4850
</table>
4951

5052
<span id="examples" class="md-typeset" style="display: block; font-weight: bold;">Examples</span>
5153
<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>
5254
```
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-
55+
regex:find('\d\d(.*)WSO2', '21 products are produced by WSO2 currently') as aboutWSO2)
5756
```
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>
57+
<p style="word-wrap: break-word">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>
5958

6059
<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>
6160
```
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-
61+
regex:find('\d\d(.*)WSO2', '21 products are produced by WSO2.', 4)
7562
```
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="https://siddhi.io/en/v5.0/docs/query-guide/#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>
63+
<p style="word-wrap: break-word">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>
8164

65+
### group *<a target="_blank" href="http://siddhi.io/en/v5.0/docs/query-guide/#function">(Function)</a>*
66+
<p style="word-wrap: break-word">Returns the subsequence captured by the given group during the regex match operation.</p>
8267
<span id="syntax" class="md-typeset" style="display: block; font-weight: bold;">Syntax</span>
68+
8369
```
8470
<STRING> regex:group(<STRING> regex, <STRING> input.sequence, <INT> group.id)
8571
```
@@ -96,23 +82,23 @@ from InputStream select inputSequence , regex:find(\d\d(.*)WSO2, 21 products are
9682
</tr>
9783
<tr>
9884
<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>
85+
<td style="vertical-align: top; word-wrap: break-word">A regular expression. For example, <code>\d\d(.*)WSO2.</code></td>
10086
<td style="vertical-align: top"></td>
10187
<td style="vertical-align: top">STRING</td>
10288
<td style="vertical-align: top">No</td>
10389
<td style="vertical-align: top">No</td>
10490
</tr>
10591
<tr>
10692
<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>
93+
<td style="vertical-align: top; word-wrap: break-word">The input sequence to be matched with the regular expression. For example, 2<code>1 products are produced by WSO2</code>.</td>
10894
<td style="vertical-align: top"></td>
10995
<td style="vertical-align: top">STRING</td>
11096
<td style="vertical-align: top">No</td>
11197
<td style="vertical-align: top">No</td>
11298
</tr>
11399
<tr>
114100
<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>
101+
<td style="vertical-align: top; word-wrap: break-word">The given group id of the regex expression. For example, <code>2</code>.</td>
116102
<td style="vertical-align: top"></td>
117103
<td style="vertical-align: top">INT</td>
118104
<td style="vertical-align: top">No</td>
@@ -123,18 +109,14 @@ from InputStream select inputSequence , regex:find(\d\d(.*)WSO2, 21 products are
123109
<span id="examples" class="md-typeset" style="display: block; font-weight: bold;">Examples</span>
124110
<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>
125111
```
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;
112+
regex:group('\d\d(.*)(WSO2.*)(WSO2.*)', '21 products are produced within 10 years by WSO2 currently by WSO2 employees', 3)
130113
```
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="https://siddhi.io/en/v5.0/docs/query-guide/#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>
114+
<p style="word-wrap: break-word">Function returns 'WSO2 employees', the subsequence captured by the groupID 3 according to the regex pattern, <code>\d\d(.*)(WSO2.*)(WSO2.*)</code>.</p>
136115

116+
### lookingAt *<a target="_blank" href="http://siddhi.io/en/v5.0/docs/query-guide/#function">(Function)</a>*
117+
<p style="word-wrap: break-word">Match 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>
137118
<span id="syntax" class="md-typeset" style="display: block; font-weight: bold;">Syntax</span>
119+
138120
```
139121
<BOOL> regex:lookingAt(<STRING> regex, <STRING> input.sequence)
140122
```
@@ -151,15 +133,15 @@ from InputStream select inputSequence, regex:group(\d\d(.*)(WSO2.*), 21 products
151133
</tr>
152134
<tr>
153135
<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>
136+
<td style="vertical-align: top; word-wrap: break-word">A regular expression. For example, <code>\d\d(.*)WSO2</code>.</td>
155137
<td style="vertical-align: top"></td>
156138
<td style="vertical-align: top">STRING</td>
157139
<td style="vertical-align: top">No</td>
158140
<td style="vertical-align: top">No</td>
159141
</tr>
160142
<tr>
161143
<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>
144+
<td style="vertical-align: top; word-wrap: break-word">The input sequence to be matched with the regular expression. For example, <code>21 products are produced by WSO2</code>.</td>
163145
<td style="vertical-align: top"></td>
164146
<td style="vertical-align: top">STRING</td>
165147
<td style="vertical-align: top">No</td>
@@ -170,25 +152,20 @@ from InputStream select inputSequence, regex:group(\d\d(.*)(WSO2.*), 21 products
170152
<span id="examples" class="md-typeset" style="display: block; font-weight: bold;">Examples</span>
171153
<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>
172154
```
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)
155+
regex:lookingAt('\d\d(.*)(WSO2.*)', '21 products are produced by WSO2 currently in Sri Lanka')
176156
```
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>
157+
<p style="word-wrap: break-word">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>
178158

179159
<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>
180160
```
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)
161+
regex:lookingAt('WSO2(.*)middleware(.*)', 'sample test string and WSO2 is situated in trace and it's a middleware company')
184162
```
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="https://siddhi.io/en/v5.0/docs/query-guide/#function">(Function)</a>*
188-
189-
<p style="word-wrap: break-word">This method attempts to match the entire 'inputSequence' against the 'regex' pattern.</p>
163+
<p style="word-wrap: break-word">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>
190164

165+
### matches *<a target="_blank" href="http://siddhi.io/en/v5.0/docs/query-guide/#function">(Function)</a>*
166+
<p style="word-wrap: break-word">Matches the entire input.sequence against the regex pattern.</p>
191167
<span id="syntax" class="md-typeset" style="display: block; font-weight: bold;">Syntax</span>
168+
192169
```
193170
<BOOL> regex:matches(<STRING> regex, <STRING> input.sequence)
194171
```
@@ -205,15 +182,15 @@ from InputStream select inputSequence, regex:lookingAt(WSO2(.*)middleware(.*), s
205182
</tr>
206183
<tr>
207184
<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>
185+
<td style="vertical-align: top; word-wrap: break-word">A regular expression. For example, <code>\d\d(.*)WSO2</code>.</td>
209186
<td style="vertical-align: top"></td>
210187
<td style="vertical-align: top">STRING</td>
211188
<td style="vertical-align: top">No</td>
212189
<td style="vertical-align: top">No</td>
213190
</tr>
214191
<tr>
215192
<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>
193+
<td style="vertical-align: top; word-wrap: break-word">The input sequence to be matched with the regular expression. For example, <code>21 products are produced by WSO2</code>.</td>
217194
<td style="vertical-align: top"></td>
218195
<td style="vertical-align: top">STRING</td>
219196
<td style="vertical-align: top">No</td>
@@ -224,17 +201,13 @@ from InputStream select inputSequence, regex:lookingAt(WSO2(.*)middleware(.*), s
224201
<span id="examples" class="md-typeset" style="display: block; font-weight: bold;">Examples</span>
225202
<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>
226203
```
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)
204+
regex:matches('WSO2(.*)middleware(.*)', 'WSO2 is situated in trace and its a middleware company')
230205
```
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>
206+
<p style="word-wrap: break-word">Function matches the entire input.sequence against <code>WSO2(.*)middleware(.*)</code> regex pattern, and as it matches it returns `true`.</p>
232207

233208
<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>
234209
```
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)
210+
regex:matches('WSO2(.*)middleware', 'WSO2 is situated in trace and its a middleware company')
238211
```
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>
212+
<p style="word-wrap: break-word">Function matches the entire input.sequence against <code>WSO2(.*)middleware</code> regex pattern. As it does not match it returns `false`.</p>
240213

0 commit comments

Comments
 (0)