This file is indexed.

/usr/share/doublecmd/doc/en/regexp.html is in doublecmd-help-en 0.8.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
  <head>
    <title>DC - Syntax of Regular Expressions</title>
    <link rel="STYLESHEET" type="text/css" href="doublecmd.css">
    <link rel="shortcut icon" href="../../pixmaps/common/favicon.ico">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>

  <body>
    <a name="topofpage"></a>
    <div class="header"><a href="index.html"><img src="../../pixmaps/common/dclogo2017.png" alt="Double Commander" height="48" width="374"></a>
      <div id="global-nav" class="nav"><a title="Double Commander" href="http://doublecmd.sourceforge.net/" target="_blank">Homepage</a></div>
    </div>
    <div class="footer"><div class="nav"><a title="Index" href="index.html">Index</a> | <a title="Previous page" href="cmds.html">Previous</a> | <a title="Next page" href="lua.html">Next</a></div></div>

    <div class="dchelpage">
      <div>
        <h1>2.9. Syntax of Regular Expressions</h1>
      </div> 

      <div>
        <h2>Content</h2>
        <dl>
          <dt>1. <a href="#preface">Introduction</a></dt>
          <dt>2. <a href="#compare">Simple matches</a></dt>
          <dt>3. <a href="#esc">Escape sequences</a></dt>
          <dt>4. <a href="#symbols">Character classes</a></dt>
          <dt>5. <a href="#meta">Metacharacters</a></dt>
          <dd>
            <dl>
              <dt>5.1. <a href="#meta-line">Metacharacters - line separators</a></dt>
              <dt>5.2. <a href="#meta-std">Metacharacters - predefined classes</a></dt>
              <dt>5.3. <a href="#meta-words">Metacharacters - word boundaries</a></dt>
              <dt>5.4. <a href="#meta-dup">Metacharacters - iterators</a></dt>
              <dt>5.5. <a href="#meta-vars">Metacharacters - alternatives</a></dt>
              <dt>5.6. <a href="#meta-sub">Metacharacters - subexpressions</a></dt>
              <dt>5.7. <a href="#meta-back">Metacharacters - backreferences</a></dt>
            </dl>
          </dd>
          <dt>6. <a href="#modifiers">Modifiers</a></dt>
          <dt>7. <a href="#perl">Perl extensions</a></dt>
        </dl>
      </div>

      <p>Double Commander uses the free Delphi library <span class="bold">TRegExpr</span> by Andrey V. Sorokin: <a href="http://www.regexpstudio.com/" target="_blank">http://www.regexpstudio.com/</a>.</p>
      <p>Most of the explanations are from the help file for this library.</p>

      <div>
        <h2>1. <a name="preface">Introduction</a></h2>
        <p>Regular Expressions are a widely-used method of specifying patterns of text to search for.</p>
        <p>Special <span class="bold">metacharacters</span> allow us to specify, for instance, that a particular string we are looking for occurs at the beginning or end of a line, or contains <span class="bold">n</span> recurrences of a certain character.<p>
        <p>Regular expressions are mainly meant for professionals, but can also be useful in the office for finding certain documents (see examples below).</p>
        <p>Double Commander supports regular expressions in the following functions:</p>
        <ul>
          <li>Commands &nbsp;&rarr; Search (in file name)</li>
          <li>In the internal Editor</li>
          <li>In the Multi-Rename tool</li>
        </ul>
        <p class="navback"><a href="#topofpage">(back to top)</a></p>	  
      </div>

      <div>
        <h2>2. <a name="compare">Simple matches</a></h2>
        <p>Any single character matches itself, unless it is a metacharacter with a special meaning described below.</p>
        <p>A series of characters matches that series of characters in the target string, so the pattern "bluh" would match "bluh'' in the target string.</p>
        <p>We can cause characters that normally function as metacharacters or <span class="bold">escape sequences</span> to be interpreted literally by 'escaping' them by preceding them with a backslash "\", for instance: metacharacter "^" match beginning of string, but "\^" match character "^", "\\" match "\" and so on.</p>
        <p>Here are some examples:</p>
        <table>
          <tr class="rowcategorytitle"><th colspan="2">Example of simple match</th></tr>
          <tr class="rowsubtitle"><th class="namecolumn">Expression</th><th class="categorydesccolumn">Result</th></tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">foobar</div></td>
            <td class="hintcell">matches string 'foobar'</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\^FooBarPtr</div></td>
            <td class="hintcell">matches '^FooBarPtr'</td>
          </tr>
        </table>
        <p class="navback"><a href="#topofpage">(back to top)</a></p>	  
      </div>

      <div>
        <h2>3. <a name="esc">Escape sequences</a></h2>
        <p>Characters may be specified using a escape sequences syntax much like that used in C and Perl: "\n'' matches a newline, "\t'' a tab, etc.</p>
        <p>More generally, \xnn, where nn is a string of hexadecimal digits, matches the character whose ASCII value is nn.</p>
        <p>If you need wide (Unicode) character code, you can use '\x{nnnn}', where 'nnnn' - one or more hexadecimal digits.</p>
        <table>
          <tr class="rowcategorytitle"><th colspan="2">Escape sequences</th></tr>
          <tr class="rowsubtitle"><th class="namecolumn">Expression</th><th class="categorydesccolumn">Result</th></tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\xnn</div></td>
            <td class="hintcell">char with hex code nn</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\x{nnnn}</div></td>
            <td class="hintcell">char with hex code nnnn (one byte for plain text and two bytes for Unicode)</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\t</div></td>
            <td class="hintcell">tab (HT/TAB), same as \x09</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\n</div></td>
            <td class="hintcell">newline (NL), same as \x0a</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\r</div></td>
            <td class="hintcell">car.return (CR), same as \x0d</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\f</div></td>
            <td class="hintcell">form feed (FF), same as \x0c</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\a</div></td>
            <td class="hintcell">alarm (bell) (BEL), same as \x07</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\e</div></td>
            <td class="hintcell">escape (ESC), same as \x1b</td>
          </tr>
        </table>
        <p>Here are some examples:</p>
        <table>
          <tr class="rowcategorytitle"><th colspan="2">Example of escape sequences</th></tr>
          <tr class="rowsubtitle"><th class="namecolumn">Expression</th><th class="categorydesccolumn">Result</th></tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">foo\x20bar</div></td>
            <td class="hintcell">matches 'foo bar' (note space in the middle)</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\tfoobar</div></td>
            <td class="hintcell">matches 'foobar' predefined by tab</td>
          </tr>
        </table>
        <p class="navback"><a href="#topofpage">(back to top)</a></p>	  
      </div>

      <div>
        <h2>4. <a name="symbols">Character classes</a></h2>
        <p>You can specify a character class, by enclosing a list of characters in [], which will match any <span class="bold">one</span> character from the list.</p>
        <p>If the first character after the "['' is "^'', the class matches any character <span class="bold">not</span> in the list.</p>
        <p>Within a list, the "-'' character is used to specify a <span class="bold">range</span>, so that a-z represents all characters between "a'' and "z'', inclusive.</p>
        <p>If you want "-'' itself to be a member of a class, put it at the start or end of the list, or escape it with a backslash.</p>
        <p>If you want ']' you may place it at the start of list or escape it with a backslash.</p>
        <table>
          <tr class="rowcategorytitle"><th colspan="2">Character classes</th></tr>
          <tr class="rowsubtitle"><th class="namecolumn">Expression</th><th class="categorydesccolumn">Result</th></tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">[-az]</div></td>
            <td class="hintcell">matches 'a', 'z' and '-'</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">[az-]</div></td>
            <td class="hintcell">matches 'a', 'z' and '-'</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">[a\-z]</div></td>
            <td class="hintcell">matches 'a', 'z' and '-'</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">[a-z]</div></td>
            <td class="hintcell">matches all twenty six small characters from 'a' to 'z'</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">[\n-\x0D]</div></td>
            <td class="hintcell">matches any of #10,#11,#12,#13.</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">[\d-t]</div></td>
            <td class="hintcell">matches any digit, '-' or 't'.</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">[]-a]</div></td>
            <td class="hintcell">matches any char from ']'..'a'.</td>
          </tr>
        </table>
        <p>Here are some examples:</p>
        <table>
          <tr class="rowcategorytitle"><th colspan="2">Example of character classes</th></tr>
          <tr class="rowsubtitle"><th class="namecolumn">Expression</th><th class="categorydesccolumn">Result</th></tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">foob[aeiou]r</div></td>
            <td class="hintcell">finds strings 'foobar', 'foober' etc. but not 'foobbr', 'foobcr' etc.</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">foob[^aeiou]r</div></td>
            <td class="hintcell">find strings 'foobbr', 'foobcr' etc. but not 'foobar', 'foober' etc.</td>
          </tr>
        </table>
        <p class="navback"><a href="#topofpage">(back to top)</a></p>	  
      </div>

      <div>
        <h2>5. <a name="meta">Metacharacters</a></h2>
        <p>Metacharacters are special characters which are the essence of Regular Expressions.</p>
        <p>There are different types of metacharacters, described below.</p>
        <p class="navback"><a href="#topofpage">(back to top)</a></p>	  
      </div>

      <div>
        <h2><a id="meta-line" name="meta-line">5.1. Metacharacters - line separators</a></h2>
        <p>Some expressions help to detect line separation.</p>
        <table>
          <tr class="rowcategorytitle"><th colspan="2">Line separators</th></tr>
          <tr class="rowsubtitle"><th class="namecolumn">Expression</th><th class="categorydesccolumn">Result</th></tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">^</div></td>
            <td class="hintcell">start of line</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">$</div></td>
            <td class="hintcell">end of line</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\A</div></td>
            <td class="hintcell">start of text</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\Z</div></td>
            <td class="hintcell">end of text</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">.</div></td>
            <td class="hintcell">any character in line</td>
          </tr>
        </table>
        <p>Here are some examples:</p>
        <table>
          <tr class="rowcategorytitle"><th colspan="2">Example with line separators</th></tr>
          <tr class="rowsubtitle"><th class="namecolumn">Expression</th><th class="categorydesccolumn">Result</th></tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">^foobar</div></td>
            <td class="hintcell">matches string 'foobar' only if it's at the beginning of line</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">foobar$</div></td>
            <td class="hintcell">matches string 'foobar' only if it's at the end of line</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">^foobar$</div></td>
            <td class="hintcell">matches string 'foobar' only if it's the only string in line</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">foob.r</div></td>
            <td class="hintcell">matches strings like 'foobar', 'foobbr', 'foob1r' and so on</td>
          </tr>
        </table>

        <p>The "^" metacharacter by default is only guaranteed to match at the beginning of the input string/text, the "$" metacharacter only at the end. Embedded line separators will not be matched by "^'' or "$''.</p>
        <p>You may, however, wish to treat a string as a multi-line buffer, such that the "^'' will match after any line separator within the string, and "$'' will match before any line separator. You can do this by switching On the <a href="http://regexpstudio.com/en/regexp_syntax.html#modifier_m" target="_blank">modifier /m</a>.</p>
        <p>The \A and \Z are just like "^'' and "$'', except that they won't match multiple times when the <a href="http://regexpstudio.com/en/regexp_syntax.html#modifier_m" target="_blank">modifier /m</a> is used, while "^'' and "$'' will match at every internal line separator.</p>
        <p>The ".'' metacharacter by default matches any character, but if you switch Off the <a href="http://regexpstudio.com/en/regexp_syntax.html#modifier_s" target="_blank">modifier /s</a>, then '.' won't match embedded line separators.</p>
        <p>TRegExpr works with line separators as recommended at <a href="http://www.unicode.org/" target="_blank">www.unicode.org</a> with <a href="http://www.unicode.org/reports/tr18/" target="_blank">Technical Standard #18</a>:</p>
        <p>"^" is at the beginning of a input string, and, if <a href="http://regexpstudio.com/en/regexp_syntax.html#modifier_m" target="_blank">modifier /m</a> is On, also immediately following any occurrence of \x0D\x0A or \x0A or \x0D (if you are using <a href="http://regexpstudio.com/en/tregexpr_interface.html#unicode" target="_blank">Unicode version</a> of TRegExpr, then also \x2028 or \x2029 or \x0B or \x0C or \x85). Note that there is no empty line within the sequence \x0D\x0A.</p>
        <p>"$" is at the end of a input string, and, if <a href="http://regexpstudio.com/en/regexp_syntax.html#modifier_m" target="_blank">modifier /m</a> is On, also immediately preceding any occurrence of \x0D\x0A or \x0A or \x0D (if you are using <a href="http://regexpstudio.com/en/tregexpr_interface.html#unicode" target="_blank">Unicode version</a> of TRegExpr, then also \x2028 or \x2029 or \x0B or \x0C or \x85). Note that there is no empty line within the sequence \x0D\x0A.</p>
        <p>"." matches any character, but if you switch Off <a href="http://regexpstudio.com/en/regexp_syntax.html#modifier_m" target="_blank">modifier /s</a> then "." doesn't match \x0D\x0A and \x0A and \x0D (if you are using <a href="http://regexpstudio.com/en/tregexpr_interface.html#unicode" target="_blank">Unicode version</a> of TRegExpr, then also \x2028 and \x2029 and \x0B and \x0C and \x85).</p>
        <p>Note that "^.*$" (an empty line pattern) does not match the empty string within the sequence \x0D\x0A, but matches the empty string within the sequence \x0A\x0D.</p>
        <p>Multi-line processing can be easily tuned for your own purpose with help of TRegExpr properties <a href="http://regexpstudio.com/en/tregexpr_interface.html#line_separators" target="_blank">LineSeparators</a> and <a href="http://regexpstudio.com/en/tregexpr_interface.html#line_separators" target="_blank">LinePairedSeparator</a>, you can use only Unix style separators \n or only DOS/Windows style \r\n or mix them together (as described above and used by default) or define your own line separators!</p>
        <p class="navback"><a href="#topofpage">(back to top)</a></p>	  
      </div>

      <div>
        <h2>5.2. <a name="meta-std">Metacharacters - predefined classes</a></h2>
        <p>Some expressions help to detect group of characters.</p>
        <table>
          <tr class="rowcategorytitle"><th colspan="2">Predefined classes</th></tr>
          <tr class="rowsubtitle"><th class="namecolumn">Expression</th><th class="categorydesccolumn">Result</th></tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\w</div></td>
            <td class="hintcell">an alphanumeric character (including "_")</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\W</div></td>
            <td class="hintcell">a nonalphanumeric</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\d</div></td>
            <td class="hintcell">a numeric character</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\D</div></td>
            <td class="hintcell">a non-numeric</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\s</div></td>
            <td class="hintcell">any space (same as [ \t\n\r\f])</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\S</div></td>
            <td class="hintcell">a non space</td>
          </tr>
        </table>
        <p>You may use \w, \d and \s within custom <span class="bold">character classes</span>.</p>
        <p>Here are some examples:</p>
        <table>
          <tr class="rowcategorytitle"><th colspan="2">Example of predefined classes</th></tr>
          <tr class="rowsubtitle"><th class="namecolumn">Expression</th><th class="categorydesccolumn">Result</th></tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">foob\dr</div></td>
            <td class="hintcell">matches strings like 'foob1r', ''foob6r' and so on but not 'foobar', 'foobbr' and so on</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">foob[\w\s]r</div></td>
            <td class="hintcell">matches strings like 'foobar', 'foob r', 'foobbr' and so on but not 'foob1r', 'foob=r' and so on</td>
          </tr>
        </table>
        <p>TRegExpr uses options <a href="http://regexpstudio.com/en/tregexpr_interface.html#tregexpr.spacechars" target="_blank">SpaceChars</a> and <a href="http://regexpstudio.com/en/tregexpr_interface.html#tregexpr.wordchars" target="_blank">WordChars</a> to redefine standard \w, \W, \s, \S, classes.</p>
        <p class="navback"><a href="#topofpage">(back to top)</a></p>	  
      </div>

      <div>
        <h2>5.3. <a name="meta-words">Metacharacters - word boundaries</a></h2>
        <p>A word boundary (\b) is a spot between two characters that has a \w on one side of it and a \W on the other side of it (in either order), counting the imaginary characters off the beginning and end of the string as matching a \W.</p>
        <table>
          <tr class="rowcategorytitle"><th colspan="2">Word boundaries</th></tr>
          <tr class="rowsubtitle"><th class="namecolumn">Expression</th><th class="categorydesccolumn">Result</th></tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\b</div></td>
            <td class="hintcell">Match a word boundary</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">\B</div></td>
            <td class="hintcell">Match a non-(word boundary)</td>
          </tr>
        </table>
        <p class="navback"><a href="#topofpage">(back to top)</a></p>	  
      </div>

      <div>
        <h2>5.4. <a name="meta-dup">Metacharacters - iterators</a></h2>
        <p>Any item of a regular expression may be followed by another type of metacharacters - iterators.</p>
        <p>Using these metacharacters you can specify the number of occurrences of the previous character, metacharacter or subexpression.</p>
        <table>
          <tr class="rowcategorytitle"><th colspan="2">Iterators</th></tr>
          <tr class="rowsubtitle"><th class="namecolumn">Expression</th><th class="categorydesccolumn">Result</th></tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">*</div></td>
            <td class="hintcell">zero or more ("greedy"), similar to {0,}</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">+</div></td>
            <td class="hintcell">one or more ("greedy"), similar to {1,}</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">?</div></td>
            <td class="hintcell">zero or one ("greedy"), similar to {0,1}</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">{n}</div></td>
            <td class="hintcell">exactly n times ("greedy")</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">{n,}</div></td>
            <td class="hintcell">at least n times ("greedy")</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">{n,m}</div></td>
            <td class="hintcell">at least n but not more than m times ("greedy")</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">*?</div></td>
            <td class="hintcell">zero or more ("non-greedy"), similar to {0,}?</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">+?</div></td>
            <td class="hintcell">one or more ("non-greedy"), similar to {1,}?</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">??</div></td>
            <td class="hintcell">zero or one ("non-greedy"), similar to {0,1}?</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">{n}?</div></td>
            <td class="hintcell">exactly n times ("non-greedy")</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">{n,}?</div></td>
            <td class="hintcell">at least n times ("non-greedy")</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">{n,m}?</div></td>
            <td class="hintcell">at least n but not more than m times ("non-greedy") </td>
          </tr>
        </table>
        <p>So, digits in curly brackets of the form {n,m}, specify the <span class="bold">minimum</span> number of times to match the item n and the <span class="bold">maximum</span> m.</p>
        <p>The form {n} is equivalent to {n,n} and matches exactly n times.</p>
        <p>The form {n,} matches n or more times.</p>
        <p>There is no limit to the size of n or m, but large numbers will chew up more memory and slow down execution.</p>
        <p>If a curly bracket occurs in any other context, it is treated as a regular character.</p>
        <p>Here are some examples:</p>
        <table>
          <tr class="rowcategorytitle"><th colspan="2">Example of iterators</th></tr>
          <tr class="rowsubtitle"><th class="namecolumn">Expression</th><th class="categorydesccolumn">Result</th></tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">foob.*r</div></td>
            <td class="hintcell">matches strings like 'foobar', 'foobalkjdflkj9r' and 'foobr'</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">foob.+r</div></td>
            <td class="hintcell">matches strings like 'foobar', 'foobalkjdflkj9r' but not 'foobr'</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">foob.?r</div></td>
            <td class="hintcell">matches strings like 'foobar', 'foobbr' and 'foobr' but not 'foobalkj9r'</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">fooba{2}r</div></td>
            <td class="hintcell">matches the string 'foobaar'</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">fooba{2,}r</div></td>
            <td class="hintcell">matches strings like 'foobaar', 'foobaaar', 'foobaaaar' etc.</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">fooba{2,3}r</div></td>
            <td class="hintcell">matches strings like 'foobaar', or 'foobaaar' but not 'foobaaaar'</td>
          </tr>
        </table>
        <p>A little explanation about "greediness".</p>
        <p>"Greedy" takes as many as possible, "non-greedy" takes as few as possible.</p>
        <p>For example, 'b+' and 'b*' applied to string 'abbbbc' return 'bbbb', 'b+?' returns 'b', 'b*?' returns empty string, 'b{2,3}?' returns 'bb', 'b{2,3}' returns 'bbb'.</p>
        <p>You can switch all iterators into "non-greedy" mode (see the <a href="http://regexpstudio.com/en/regexp_syntax.html#modifier_g" target="_blank">modifier /g</a>).</p>
        <p class="navback"><a href="#topofpage">(back to top)</a></p>	  
      </div>

      <div>
        <h2>5.5. <a name="meta-vars">Metacharacters - alternatives</a></h2>
        <p>You can specify a series of <span class="bold">alternatives</span> for a pattern using "|'' to separate them, so that fee|fie|foe will match any of "fee'', "fie'', or "foe'' in the target string (as would f(e|i|o)e).</p>
        <p>The first alternative includes everything from the last pattern delimiter ("('', "['', or the beginning of the pattern) up to the first "|'', and the last alternative contains everything from the last "|'' to the next pattern delimiter.</p>
        <p>For this reason, it's common practice to include alternatives in parentheses, to minimize confusion about where they start and end.</p>
        <p>Alternatives are tried from left to right, so the first alternative found for which the entire expression matches, is the one that is chosen.</p>
        <p>This means that alternatives are not necessarily greedy.</p>
        <p>For example: when matching foo|foot against "barefoot'', only the "foo'' part will match, as that is the first alternative tried, and it successfully matches the target string. (This might not seem important, but it is important when you are capturing matched text using parentheses.)</p>
        <p>Also remember that "|'' is interpreted as a literal within square brackets, so if you write [fee|fie|foe] you're really only matching [feio|].</p>
        <p>Here are some examples:</p>
        <table>
          <tr class="rowcategorytitle"><th colspan="2">Example of alternatives</th></tr>
          <tr class="rowsubtitle"><th class="namecolumn">Expression</th><th class="categorydesccolumn">Result</th></tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">foo(bar|foo)</div></td>
            <td class="hintcell">matches strings 'foobar' or 'foofoo'.</td>
          </tr>
        </table>
        <p class="navback"><a href="#topofpage">(back to top)</a></p>	  
      </div>

      <div>
        <h2>5.6. <a name="meta-sub">Metacharacters - subexpressions</a></h2>
        <p>The bracketing construct ( ... ) may also be used for define regular expression subexpressions.</p>
        <p>After search you can call any subexpression using properties MatchPos, MatchLen and <a href="http://regexpstudio.com/en/tregexpr_interface.html#tregexpr.match" target="_blank">Match</a>, also you can use subexpressions as masks using <a href="http://regexpstudio.com/en/tregexpr_interface.html#tregexpr.substitute" target="_blank">Substitute</a>).</p>
        <p>Subexpressions are numbered based on the left to right order of their opening parenthesis.</p>
        <p>First subexpression has number '1' (whole regular expression match has number '0' - you can substitute it in <a href="http://regexpstudio.com/en/tregexpr_interface.html#tregexpr.substitute" target="_blank">Substitute</a> as '$0' or '$&').</p>
        <p>Here are some examples:</p>
        <table>
          <tr class="rowcategorytitle"><th colspan="2">Subexpressions</th></tr>
          <tr class="rowsubtitle"><th class="namecolumn">Expression</th><th class="categorydesccolumn">Result</th></tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">(foobar){8,10}</div></td>
            <td class="hintcell">matches strings which contain 8, 9 or 10 instances of the 'foobar'</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">foob([0-9]|a+)r</div></td>
            <td class="hintcell">matches 'foob0r', 'foob1r' , 'foobar', 'foobaar', 'foobaar' etc.</td>
          </tr>
        </table>
        <p class="navback"><a href="#topofpage">(back to top)</a></p>	  
      </div>

      <div>
        <h2>5.7. <a name="meta-back">Metacharacters - backreferences</a></h2>
        <p>Metacharacters \1 through \9 are interpreted as backreferences. \&lt;n&gt; matches previously matched subexpression #&lt;n&gt;.</p>
        <p>Here are some examples:</p>
        <table>
          <tr class="rowcategorytitle"><th colspan="2">Examples of backreferences</th></tr>
          <tr class="rowsubtitle"><th class="namecolumn">Expression</th><th class="categorydesccolumn">Result</th></tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">(.)\1+</div></td>
            <td class="hintcell">matches 'aaaa' and 'cc'.</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">(.+)\1+</div></td>
            <td class="hintcell">also match 'abab' and '123123'</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">(['"]?)(\d+)\1</div></td>
            <td class="hintcell">matches '"13" (in double quotes), or '4' (in single quotes) or 77 (without quotes) etc</td>
          </tr>
        </table>
        <p class="navback"><a href="#topofpage">(back to top)</a></p>	  
      </div>

      <div>
        <h2>6. <a name="modifiers">Modifiers</a></h2>
        <p>Modifiers are for changing behaviour of regular expressions.</p>
        <p>Any of these modifiers may be embedded within the regular expression itself using the <a href="http://regexpstudio.com/en/regexp_syntax.html#inline_modifiers" target="_blank">(?...)</a> construct.</p>
        <dl>
          <dt><tt>i</tt></dt>
          <dd>Do case-insensitive pattern matching (using installed in your system locale settings), see also <a href="http://regexpstudio.com/en/tregexpr_interface.html#invertcase" target="_blank">InvertCase</a>.</dd>
          <dt><tt>m</tt></dt>
          <dd>Treat string as multiple lines. That is, change "^'' and "$'' from matching at only the very start or end of the string to the start or end of any line anywhere within the string, see also <a href="http://regexpstudio.com/en/tregexpr_interface.html#line_separators" target="_blank">Line separators</a>.</dd>
          <dt><tt>s</tt></dt>
          <dd>Treat string as single line. That is, change ".'' to match any character whatsoever, even a line separator (see also <a href="http://regexpstudio.com/en/tregexpr_interface.html#line_separators" target="_blank">Line separators</a>), which it normally would not match.</dd>
          <dt><tt>g</tt></dt>
          <dd>Non standard modifier. Switching it Off you'll switch all following operators into non-greedy mode (by default this modifier is On). So, if modifier /g is Off then '+' works as '+?', '*' as '*?' and so on </dd>
          <dt><tt>x</tt></dt>
          <dd>Extend your pattern's legibility by permitting whitespace and comments (see explanation below).</dd>
          <dt><tt>r</tt></dt>
          <dd>Non-standard modifier. If is set then range 'а-я' additional include Russian letter 'ё', 'А-Я' additional include 'Ё', and 'а-Я' include all Russian symbols.  
            Sorry for foreign users, but it's set by default. If you want switch if off by default - set false to global variable <a href="http://www.regexpstudio.com/TRegExpr/Help/tregexpr_interface.html#modifier_defs">RegExprModifierR</a>.</dd>
        </dl>
        <p>The <a href="http://regexpstudio.com/en/tregexpr_interface.html#tregexpr.modifier_x" target="_blank">modifier /x</a> itself needs a little more explanation.</p>
        <p>It tells to ignore whitespace that is neither backslashed nor within a character class.</p>
        <p>You can use this to break up your regular expression into (slightly) more readable parts.</p>
        <p>The # character is also treated as a metacharacter introducing a comment, for example:</p>
        <pre class="CODE">
	  (
		(abc) # comment 1  
		  |   # You can use spaces to format r.e. - TRegExpr ignores it  
		(efg) # comment 2  
	  )</pre>
        <p>This also means that if you want real whitespace or # characters in the pattern (outside a character class, where they are unaffected by /x), that you'll either have to escape them or encode them using octal or hex escapes.</p>
        <p>Taken together, these features go a long way towards making regular expressions text more readable.</p>
        <p class="navback"><a href="#topofpage">(back to top)</a></p>	  
      </div>

      <div>
        <h2>7. <a name="perl">Perl extensions</a></h2>
        <p class="bold">(?imsxr-imsxr)</p>
        <p>You may use it into regular expression for modifying modifiers by the fly.</p>
        <p>If this construction is inlined into subexpression, then it effects only into this subexpression.</p>
        <p>Here are some examples:</p>
        <table>
          <tr class="rowcategorytitle"><th colspan="2">Examples of Perl extensions</th></tr>
          <tr class="rowsubtitle"><th class="namecolumn">Expression</th><th class="categorydesccolumn">Result</th></tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">(?i)Saint-Petersburg</div></td>
            <td class="hintcell">matches 'Saint-petersburg' and 'Saint-Petersburg'</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">(?i)Saint-(?-i)Petersburg</div></td>
            <td class="hintcell">matches 'Saint-Petersburg' but not 'Saint-petersburg'</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">(?i)(Saint-)?Petersburg</div></td>
            <td class="hintcell">matches 'Saint-petersburg' and 'saint-petersburg'</td>
          </tr>
          <tr>
            <td class="varcell"><div class="firstcolumnaleft">((?i)Saint-)?Petersburg</div></td>
            <td class="hintcell">matches 'saint-Petersburg', but not 'saint-petersburg'</td>
          </tr>
        </table>
        <p class="bold">(?#text)</p>
        <p>A comment, the text is ignored.</p>
        <p>Note that TRegExpr closes the comment as soon as it sees a ")", so there is no way to put a literal ")" in the comment.</p>
        <p class="navback"><a href="#topofpage">(back to top)</a></p>	  
        <BR>
      </div>
    </div>
    <div class="footer"><div class="nav"><a title="Index" href="index.html">Index</a> | <a title="Previous page" href="cmds.html">Previous</a> | <a title="Next page" href="lua.html">Next</a></div></div>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
  </body>
</html>