-
Notifications
You must be signed in to change notification settings - Fork 2
/
syntax_reference.xml
401 lines (396 loc) · 17.1 KB
/
syntax_reference.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright 2009 Eric Doughty-Papassideris. All Rights Reserved.
Most content composed from other sources - see quickref/dialects XPath for details - they retain copyright and stuff.
This file is part of RXBuild.
RXBuild is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
RXBuild is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU General Public License
along with RXBuild. If not, see <http://www.gnu.org/licenses/>.
-->
<quickref>
<dialects>
<dialect id="ecma">
<name>ECMAscript/JavaScript</name>
<description>The javascript regular expression dialect</description>
<source>
Content copied (with no garantees what so ever) from <a href="https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Global_Objects/RegExp">Mozilla Developper Center - Core JavaScript 1.5 Reference</a>
</source>
</dialect>
</dialects>
<category name="Operators">
<item dialect="ecma">
<sample>^</sample>
<description>
<p>
Matches beginning of input. If the multiline flag is set to true, also matches immediately after a line break character.
</p>
<p>
For example, <code>/^A/</code> does not match the 'A' in "an A", but does match the first 'A' in "An A."
</p>
</description>
</item>
<item dialect="ecma">
<sample>$</sample>
<description>
<p>
Matches end of input. If the multiline flag is set to true, also matches immediately before a line break character.
</p>
<p>
For example, <code>/t$/</code> does not match the 't' in "eater", but does match it in "eat".
</p>
</description>
</item>
<item dialect="ecma">
<sample>*</sample>
<description>
<p>
Matches the preceding item 0 or more times.
</p>
<p>
For example, <code>/bo*/</code> matches 'boooo' in "A ghost booooed" and 'b' in "A bird warbled", but nothing in "A goat grunted".
</p>
</description>
</item>
<item dialect="ecma">
<sample>+</sample>
<description>
<p>
Matches the preceding item 1 or more times. Equivalent to <code>{1,}</code>.
</p>
<p>
For example, <code>/a+/</code> matches the 'a' in "candy" and all the a's in "caaaaaaandy".
</p>
</description>
</item>
<item dialect="ecma">
<sample>?</sample>
<description>
<p>
Matches the preceding item 0 or 1 time.
</p>
<p>
For example, <code>/e?le?/</code> matches the 'el' in "angel" and the 'le' in "angle."
</p>
<p>
If used immediately after any of the quantifiers <code>*</code>, <code>+</code>, <code>?</code>, or <code>{}</code>, makes the quantifier non-greedy (matching the minimum number of times), as opposed to the default, which is greedy (matching the maximum number of times).
</p>
<p>
Also used in lookahead assertions, described under <code>(?=)</code>, <code>(?!)</code>, and <code>(?:)</code> in this table.
</p>
</description>
</item>
<item dialect="ecma">
<sample>.</sample>
<description>
<p>
(The decimal point) matches any single character except the newline characters: \n \r \u2028 or \u2029. (<code>[\s\S]</code> can be used to match any character including newlines.)
</p>
<p>
For example, <code>/.n/</code> matches 'an' and 'on' in "nay, an apple is on the tree", but not 'nay'.
</p>
</description>
</item>
<item dialect="ecma">
<sample><em>x</em>|<em>y</em></sample>
<description>
<p>
Matches either <code><em>x</em></code> or <code><em>y</em></code>.
</p>
<p>
For example, <code>/green|red/</code> matches 'green' in "green apple" and 'red' in "red apple."
</p>
</description>
</item>
<item dialect="ecma">
<sample>{<em>n</em>}</sample>
<description>
<p>
Where <code><em>n</em></code> is a positive integer. Matches exactly <code><em>n</em></code> occurrences of the preceding item.
</p>
<p>
For example, <code>/a{2}/</code> doesn't match the 'a' in "candy," but it matches all of the a's in "caandy," and the first two a's in "caaandy."
</p>
</description>
</item>
<item dialect="ecma">
<sample>{<em>n</em>,}</sample>
<description>
<p>
Where <code><em>n</em></code> is a positive integer. Matches at least <code><em>n</em></code> occurrences of the preceding item.
</p>
<p>
For example, <code>/a{2,}/</code> doesn't match the 'a' in "candy", but matches all of the a's in "caandy" and in "caaaaaaandy."
</p>
</description>
</item>
<item dialect="ecma">
<sample>{<em>n</em>,<em>m</em>}</sample>
<description>
<p>
Where <code><em>n</em></code> and <code><em>m</em></code> are positive integers. Matches at least <code><em>n</em></code> and at most <code><em>m</em></code> occurrences of the preceding item.
</p>
<p>
For example, <code>/a{1,3}/</code> matches nothing in "cndy", the 'a' in "candy," the first two a's in "caandy," and the first three a's in "caaaaaaandy". Notice that when matching "caaaaaaandy", the match is "aaa", even though the original string had more a's in it.
</p>
</description>
</item>
<item dialect="ecma">
<sample>[<em>xyz</em>]</sample>
<description>
<p>
A character set. Matches any one of the enclosed characters. You can specify a range of characters by using a hyphen.
</p>
<p>
For example, <code>[abcd]</code> is the same as <code>[a-d]</code>. They match the 'b' in "brisket" and the 'c' in "ache".
</p>
</description>
</item>
<item dialect="ecma">
<sample>[^<em>xyz</em>]</sample>
<description>
<p>
A negated or complemented character set. That is, it matches anything that is not enclosed in the brackets. You can specify a range of characters by using a hyphen.
</p>
<p>
For example, <code>[^abc]</code> is the same as <code>[^a-c]</code>. They initially match 'r' in "brisket" and 'h' in "chop."
</p>
</description>
</item>
<item dialect="ecma">
<sample>[\b]</sample>
<description>
<p>
Matches a backspace. (Not to be confused with <code>\b</code>.)
</p>
</description>
</item>
</category>
<category name="Groups">
<item dialect="ecma">
<sample>(<em>x</em>)</sample>
<description>
<p>
Matches <code><em>x</em></code> and remembers the match. These are called capturing parentheses.
</p>
<p>
For example, <code>/(foo)/</code> matches and remembers 'foo' in "foo bar." The matched substring can be recalled from the resulting array's elements <code>[1], ..., [<em>n</em>]</code> or from the predefined <code>RegExp</code> object's properties <code>$1, ..., $9</code>.
</p>
</description>
</item>
<item dialect="ecma">
<sample>(?:<em>x</em>)</sample>
<description>
<p>
Matches <code><em>x</em></code> but does not remember the match. These are called non-capturing parentheses. The matched substring can not be recalled from the resulting array's elements <code>[1], ..., [<em>n</em>]</code> or from the predefined <code>RegExp</code> object's properties <code>$1, ..., $9</code>.
</p>
</description>
</item>
<item dialect="ecma">
<sample><em>x</em>(?=<em>y</em>)</sample>
<description>
<p>
Matches <code><em>x</em></code> only if <code><em>x</em></code> is followed by <code><em>y</em></code>. For example, <code>/Jack(?=Sprat)/</code> matches 'Jack' only if it is followed by 'Sprat'. <code>/Jack(?=Sprat|Frost)/</code> matches 'Jack' only if it is followed by 'Sprat' or 'Frost'. However, neither 'Sprat' nor 'Frost' is part of the match results.
</p>
</description>
</item>
<item dialect="ecma">
<sample><em>x</em>(?!<em>y</em>)</sample>
<description>
<p>
Matches <code><em>x</em></code> only if <code><em>x</em></code> is not followed by <code><em>y</em></code>. For example, <code>/\d+(?!\.)/</code> matches a number only if it is not followed by a decimal point.
</p>
<p>
<code>/\d+(?!\.)/.exec("3.141")</code> matches 141 but not 3.141.
</p>
</description>
</item>
</category>
<category name="Escaping">
<item dialect="ecma">
<sample>\b</sample>
<description>
<p>
Matches a word boundary, such as a space. (Not to be confused with <code>[\b]</code>.)
</p>
<p>
For example, <code>/\bn\w/</code> matches the 'no' in "noonday"; <code>/\wy\b/</code> matches the 'ly' in "possibly yesterday."
</p>
</description>
</item>
<item dialect="ecma">
<sample>\B</sample>
<description>
<p>
Matches a non-word boundary.
</p>
<p>
For example, <code>/\w\Bn/</code> matches 'on' in "noonday", and <code>/y\B\w/</code> matches 'ye' in "possibly yesterday."
</p>
</description>
</item>
<item dialect="ecma">
<sample>\c<em>X</em></sample>
<description>
<p>
Where <code><em>X</em></code> is a letter from A - Z. Matches a control character in a string.
</p>
<p>
For example, <code>/\cM/</code> matches control-M in a string.
</p>
</description>
</item>
<item dialect="ecma">
<sample>\d</sample>
<description>
<p>
Matches a digit character in the basic Latin alphabet. Equivalent to <code>[0-9]</code>.
</p>
<p>
<strong>Note</strong>: In Firefox 2 and earlier, matches a digit character from any alphabet. ( <span class="lang lang-*"><a rel="external nofollow" target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=378738" title="https://bugzilla.mozilla.org/show_bug.cgi?id=378738" class=" link-https">bug 378738</a></span> )
</p>
<p>
For example, <code>/\d/</code> or <code>/[0-9]/</code> matches '2' in "B2 is the suite number."
</p>
</description>
</item>
<item dialect="ecma">
<sample>\D</sample>
<description>
<p>
Matches any non-digit character in the basic Latin alphabet. Equivalent to <code>[^0-9]</code>.
</p>
<p>
<strong>Note</strong>: In Firefox 2 and earlier, all alphabet. ( <span class="lang lang-*"><a rel="external nofollow" target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=378738" title="https://bugzilla.mozilla.org/show_bug.cgi?id=378738" class=" link-https">bug 378738</a></span> )
</p>
<p>
For example, <code>/\D/</code> or <code>/[^0-9]/</code> matches 'B' in "B2 is the suite number."
</p>
</description>
</item>
<item dialect="ecma">
<sample>\f</sample>
<description>
<p>
Matches a form-feed.
</p>
</description>
</item>
<item dialect="ecma">
<sample>\n</sample>
<description>
<p>
Matches a linefeed.
</p>
</description>
</item>
<item dialect="ecma">
<sample>\r</sample>
<description>
<p>
Matches a carriage return.
</p>
</description>
</item>
<item dialect="ecma">
<sample>\s</sample>
<description>
<p>
Matches a single white space character, including space, tab, form feed, line feed and other unicode spaces.<span class="lang lang-en"><small><sup id="ref_equivalent_s" class="plainlinksneverexpand"><a rel="internal" href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/RegExp#endnote_equivalent_s">equivalent_s</a></sup></small></span>
</p>
<p>
For example, <code>/\s\w*/</code> matches ' bar' in "foo bar."
</p>
</description>
</item>
<item dialect="ecma">
<sample>\S</sample>
<description>
<p>
Matches a single character other than white space.<span class="lang lang-en"><small><sup id="ref_equivalent_S" class="plainlinksneverexpand"><a rel="internal" href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/RegExp#endnote_equivalent_S">equivalent_S</a></sup></small></span>
</p>
<p>
For example, <code>/\S\w*/</code> matches 'foo' in "foo bar."
</p>
</description>
</item>
<item dialect="ecma">
<sample>\t</sample>
<description>
<p>
Matches a tab.
</p>
</description>
</item>
<item dialect="ecma">
<sample>\v</sample>
<description>
<p>
Matches a vertical tab.
</p>
</description>
</item>
<item dialect="ecma">
<sample>\w</sample>
<description>
<p>
Matches any alphanumeric character from the basic Latin alphabet, including the underscore. Equivalent to <code>[A-Za-z0-9_]</code>.
</p>
<p>
For example, <code>/\w/</code> matches 'a' in "apple," '5' in "$5.28," and '3' in "3D."
</p>
</description>
</item>
<item dialect="ecma">
<sample>\W</sample>
<description>
<p>
Matches any character that is not a word character from the basic Latin alphabet. Equivalent to <code>[^A-Za-z0-9_]</code>.
</p>
<p>
For example, <code>/\W/</code> or <code>/[^$A-Za-z0-9_]/</code> matches '%' in "50%."
</p>
</description>
</item>
<item dialect="ecma">
<sample>\<em>n</em></sample>
<description>
<p>
Where <code><em>n</em></code> is a positive integer. A back reference to the last substring matching the n parenthetical in the regular expression (counting left parentheses).
</p>
<p>
For example, <code>/apple(,)\sorange\1/</code> matches 'apple, orange,' in "apple, orange, cherry, peach." A more complete example follows this table.
</p>
</description>
</item>
<item dialect="ecma">
<sample>\0</sample>
<description>
<p>
Matches a NUL character. Do not follow this with another digit.
</p>
</description>
</item>
<item dialect="ecma">
<sample>\x<em>hh</em></sample>
<description>
<p>
Matches the character with the code <code><em>hh</em></code> (two hexadecimal digits)
</p>
</description>
</item>
<item dialect="ecma">
<sample>\u<em>hhhh</em></sample>
<description>
<p>
Matches the character with the Unicode value <code><em>hhhh</em></code> (four hexadecimal digits).
</p>
</description>
</item>
</category>
</quickref>