packaging: remove old options to find hidden files
[platform/upstream/findutils.git] / doc / regexprops.texi
1 @c Copyright (C) 1994, 1996, 1998, 2000, 2001, 2003, 2004, 2005, 2006,
2 @c 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
3 @c
4 @c Permission is granted to copy, distribute and/or modify this document
5 @c under the terms of the GNU Free Documentation License, Version 1.3 or
6 @c any later version published by the Free Software Foundation; with no
7 @c Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
8 @c Texts.  A copy of the license is included in the ``GNU Free
9 @c Documentation License'' file as part of this distribution.
10
11 @c this regular expression description is for: findutils
12
13 @menu
14 * findutils-default regular expression syntax::
15 * awk regular expression syntax::
16 * egrep regular expression syntax::
17 * emacs regular expression syntax::
18 * gnu-awk regular expression syntax::
19 * grep regular expression syntax::
20 * posix-awk regular expression syntax::
21 * posix-basic regular expression syntax::
22 * posix-egrep regular expression syntax::
23 * posix-extended regular expression syntax::
24 @end menu
25
26 @node findutils-default regular expression syntax
27 @subsection @samp{findutils-default} regular expression syntax
28
29
30 The character @samp{.} matches any single character.
31
32
33 @table @samp
34
35 @item +
36 indicates that the regular expression should match one or more occurrences of the previous atom or regexp.
37 @item ?
38 indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
39 @item \+
40 matches a @samp{+}
41 @item \?
42 matches a @samp{?}.
43 @end table
44
45
46 Bracket expressions are used to match ranges of characters.  Bracket expressions where the range is backward, for example @samp{[z-a]}, are ignored.  Within square brackets, @samp{\} is taken literally.  Character classes are not supported, so for example you would need to use @samp{[0-9]} instead of @samp{[[:digit:]]}.
47
48 GNU extensions are supported:
49 @enumerate
50
51 @item @samp{\w} matches a character within a word
52
53 @item @samp{\W} matches a character which is not within a word
54
55 @item @samp{\<} matches the beginning of a word
56
57 @item @samp{\>} matches the end of a word
58
59 @item @samp{\b} matches a word boundary
60
61 @item @samp{\B} matches characters which are not a word boundary
62
63 @item @samp{\`} matches the beginning of the whole input
64
65 @item @samp{\'} matches the end of the whole input
66
67 @end enumerate
68
69
70 Grouping is performed with backslashes followed by parentheses @samp{\(}, @samp{\)}.  A backslash followed by a digit acts as a back-reference and matches the same thing as the previous grouped expression indicated by that number.  For example @samp{\2} matches the second group expression.  The order of group expressions is determined by the position of their opening parenthesis @samp{\(}.
71
72 The alternation operator is @samp{\|}.
73
74 The character @samp{^} only represents the beginning of a string when it appears:
75 @enumerate
76
77 @item
78 At the beginning of a regular expression
79
80 @item After an open-group, signified by
81 @samp{\(}
82
83 @item After the alternation operator @samp{\|}
84
85 @end enumerate
86
87
88 The character @samp{$} only represents the end of a string when it appears:
89 @enumerate
90
91 @item At the end of a regular expression
92
93 @item Before a close-group, signified by
94 @samp{\)}
95 @item Before the alternation operator @samp{\|}
96
97 @end enumerate
98
99
100 @samp{*}, @samp{+} and @samp{?} are special at any point in a regular expression except:
101 @enumerate
102
103 @item At the beginning of a regular expression
104
105 @item After an open-group, signified by
106 @samp{\(}
107 @item After the alternation operator @samp{\|}
108
109 @end enumerate
110
111
112
113
114 The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
115
116
117 @node awk regular expression syntax
118 @subsection @samp{awk} regular expression syntax
119
120
121 The character @samp{.} matches any single character except the null character.
122
123
124 @table @samp
125
126 @item +
127 indicates that the regular expression should match one or more occurrences of the previous atom or regexp.
128 @item ?
129 indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
130 @item \+
131 matches a @samp{+}
132 @item \?
133 matches a @samp{?}.
134 @end table
135
136
137 Bracket expressions are used to match ranges of characters.  Bracket expressions where the range is backward, for example @samp{[z-a]}, are invalid.  Within square brackets, @samp{\} can be used to quote the following character.  Character classes are supported; for example @samp{[[:digit:]]} will match a single decimal digit.
138
139 GNU extensions are not supported and so @samp{\w}, @samp{\W}, @samp{\<}, @samp{\>}, @samp{\b}, @samp{\B}, @samp{\`}, and @samp{\'} match @samp{w}, @samp{W}, @samp{<}, @samp{>}, @samp{b}, @samp{B}, @samp{`}, and @samp{'} respectively.
140
141 Grouping is performed with parentheses @samp{()}.  An unmatched @samp{)} matches just itself.  A backslash followed by a digit matches that digit.
142
143 The alternation operator is @samp{|}.
144
145 The characters @samp{^} and @samp{$} always represent the beginning and end of a string respectively, except within square brackets.  Within brackets, @samp{^} can be used to invert the membership of the character class being specified.
146
147 @samp{*}, @samp{+} and @samp{?} are special at any point in a regular expression except:
148 @enumerate
149
150 @item At the beginning of a regular expression
151
152 @item After an open-group, signified by
153 @samp{(}
154 @item After the alternation operator @samp{|}
155
156 @end enumerate
157
158
159
160
161 The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
162
163
164 @node egrep regular expression syntax
165 @subsection @samp{egrep} regular expression syntax
166
167
168 The character @samp{.} matches any single character except newline.
169
170
171 @table @samp
172
173 @item +
174 indicates that the regular expression should match one or more occurrences of the previous atom or regexp.
175 @item ?
176 indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
177 @item \+
178 matches a @samp{+}
179 @item \?
180 matches a @samp{?}.
181 @end table
182
183
184 Bracket expressions are used to match ranges of characters.  Bracket expressions where the range is backward, for example @samp{[z-a]}, are ignored.  Within square brackets, @samp{\} is taken literally.  Character classes are supported; for example @samp{[[:digit:]]} will match a single decimal digit.  Non-matching lists @samp{[^@dots{}]} do not ever match newline.
185
186 GNU extensions are supported:
187 @enumerate
188
189 @item @samp{\w} matches a character within a word
190
191 @item @samp{\W} matches a character which is not within a word
192
193 @item @samp{\<} matches the beginning of a word
194
195 @item @samp{\>} matches the end of a word
196
197 @item @samp{\b} matches a word boundary
198
199 @item @samp{\B} matches characters which are not a word boundary
200
201 @item @samp{\`} matches the beginning of the whole input
202
203 @item @samp{\'} matches the end of the whole input
204
205 @end enumerate
206
207
208 Grouping is performed with parentheses @samp{()}.  A backslash followed by a digit acts as a back-reference and matches the same thing as the previous grouped expression indicated by that number.  For example @samp{\2} matches the second group expression.  The order of group expressions is determined by the position of their opening parenthesis @samp{(}.
209
210 The alternation operator is @samp{|}.
211
212 The characters @samp{^} and @samp{$} always represent the beginning and end of a string respectively, except within square brackets.  Within brackets, @samp{^} can be used to invert the membership of the character class being specified.
213
214 The characters @samp{*}, @samp{+} and @samp{?} are special anywhere in a regular expression.
215
216
217
218 The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
219
220
221 @node emacs regular expression syntax
222 @subsection @samp{emacs} regular expression syntax
223
224
225 The character @samp{.} matches any single character except newline.
226
227
228 @table @samp
229
230 @item +
231 indicates that the regular expression should match one or more occurrences of the previous atom or regexp.
232 @item ?
233 indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
234 @item \+
235 matches a @samp{+}
236 @item \?
237 matches a @samp{?}.
238 @end table
239
240
241 Bracket expressions are used to match ranges of characters.  Bracket expressions where the range is backward, for example @samp{[z-a]}, are ignored.  Within square brackets, @samp{\} is taken literally.  Character classes are not supported, so for example you would need to use @samp{[0-9]} instead of @samp{[[:digit:]]}.
242
243 GNU extensions are supported:
244 @enumerate
245
246 @item @samp{\w} matches a character within a word
247
248 @item @samp{\W} matches a character which is not within a word
249
250 @item @samp{\<} matches the beginning of a word
251
252 @item @samp{\>} matches the end of a word
253
254 @item @samp{\b} matches a word boundary
255
256 @item @samp{\B} matches characters which are not a word boundary
257
258 @item @samp{\`} matches the beginning of the whole input
259
260 @item @samp{\'} matches the end of the whole input
261
262 @end enumerate
263
264
265 Grouping is performed with backslashes followed by parentheses @samp{\(}, @samp{\)}.  A backslash followed by a digit acts as a back-reference and matches the same thing as the previous grouped expression indicated by that number.  For example @samp{\2} matches the second group expression.  The order of group expressions is determined by the position of their opening parenthesis @samp{\(}.
266
267 The alternation operator is @samp{\|}.
268
269 The character @samp{^} only represents the beginning of a string when it appears:
270 @enumerate
271
272 @item
273 At the beginning of a regular expression
274
275 @item After an open-group, signified by
276 @samp{\(}
277
278 @item After the alternation operator @samp{\|}
279
280 @end enumerate
281
282
283 The character @samp{$} only represents the end of a string when it appears:
284 @enumerate
285
286 @item At the end of a regular expression
287
288 @item Before a close-group, signified by
289 @samp{\)}
290 @item Before the alternation operator @samp{\|}
291
292 @end enumerate
293
294
295 @samp{*}, @samp{+} and @samp{?} are special at any point in a regular expression except:
296 @enumerate
297
298 @item At the beginning of a regular expression
299
300 @item After an open-group, signified by
301 @samp{\(}
302 @item After the alternation operator @samp{\|}
303
304 @end enumerate
305
306
307
308
309 The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
310
311
312 @node gnu-awk regular expression syntax
313 @subsection @samp{gnu-awk} regular expression syntax
314
315
316 The character @samp{.} matches any single character.
317
318
319 @table @samp
320
321 @item +
322 indicates that the regular expression should match one or more occurrences of the previous atom or regexp.
323 @item ?
324 indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
325 @item \+
326 matches a @samp{+}
327 @item \?
328 matches a @samp{?}.
329 @end table
330
331
332 Bracket expressions are used to match ranges of characters.  Bracket expressions where the range is backward, for example @samp{[z-a]}, are invalid.  Within square brackets, @samp{\} can be used to quote the following character.  Character classes are supported; for example @samp{[[:digit:]]} will match a single decimal digit.
333
334 GNU extensions are supported:
335 @enumerate
336
337 @item @samp{\w} matches a character within a word
338
339 @item @samp{\W} matches a character which is not within a word
340
341 @item @samp{\<} matches the beginning of a word
342
343 @item @samp{\>} matches the end of a word
344
345 @item @samp{\b} matches a word boundary
346
347 @item @samp{\B} matches characters which are not a word boundary
348
349 @item @samp{\`} matches the beginning of the whole input
350
351 @item @samp{\'} matches the end of the whole input
352
353 @end enumerate
354
355
356 Grouping is performed with parentheses @samp{()}.  An unmatched @samp{)} matches just itself.  A backslash followed by a digit acts as a back-reference and matches the same thing as the previous grouped expression indicated by that number.  For example @samp{\2} matches the second group expression.  The order of group expressions is determined by the position of their opening parenthesis @samp{(}.
357
358 The alternation operator is @samp{|}.
359
360 The characters @samp{^} and @samp{$} always represent the beginning and end of a string respectively, except within square brackets.  Within brackets, @samp{^} can be used to invert the membership of the character class being specified.
361
362 @samp{*}, @samp{+} and @samp{?} are special at any point in a regular expression except:
363 @enumerate
364
365 @item At the beginning of a regular expression
366
367 @item After an open-group, signified by
368 @samp{(}
369 @item After the alternation operator @samp{|}
370
371 @end enumerate
372
373
374 Intervals are specified by @samp{@{} and @samp{@}}.  Invalid intervals are treated as literals, for example @samp{a@{1} is treated as @samp{a\@{1}
375
376 The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
377
378
379 @node grep regular expression syntax
380 @subsection @samp{grep} regular expression syntax
381
382
383 The character @samp{.} matches any single character except newline.
384
385
386 @table @samp
387
388 @item \+
389 indicates that the regular expression should match one or more occurrences of the previous atom or regexp.
390 @item \?
391 indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
392 @item + and ?
393 match themselves.
394 @end table
395
396
397 Bracket expressions are used to match ranges of characters.  Bracket expressions where the range is backward, for example @samp{[z-a]}, are ignored.  Within square brackets, @samp{\} is taken literally.  Character classes are supported; for example @samp{[[:digit:]]} will match a single decimal digit.  Non-matching lists @samp{[^@dots{}]} do not ever match newline.
398
399 GNU extensions are supported:
400 @enumerate
401
402 @item @samp{\w} matches a character within a word
403
404 @item @samp{\W} matches a character which is not within a word
405
406 @item @samp{\<} matches the beginning of a word
407
408 @item @samp{\>} matches the end of a word
409
410 @item @samp{\b} matches a word boundary
411
412 @item @samp{\B} matches characters which are not a word boundary
413
414 @item @samp{\`} matches the beginning of the whole input
415
416 @item @samp{\'} matches the end of the whole input
417
418 @end enumerate
419
420
421 Grouping is performed with backslashes followed by parentheses @samp{\(}, @samp{\)}.  A backslash followed by a digit acts as a back-reference and matches the same thing as the previous grouped expression indicated by that number.  For example @samp{\2} matches the second group expression.  The order of group expressions is determined by the position of their opening parenthesis @samp{\(}.
422
423 The alternation operator is @samp{\|}.
424
425 The character @samp{^} only represents the beginning of a string when it appears:
426 @enumerate
427
428 @item
429 At the beginning of a regular expression
430
431 @item After an open-group, signified by
432 @samp{\(}
433
434 @item After a newline
435
436 @item After the alternation operator @samp{\|}
437
438 @end enumerate
439
440
441 The character @samp{$} only represents the end of a string when it appears:
442 @enumerate
443
444 @item At the end of a regular expression
445
446 @item Before a close-group, signified by
447 @samp{\)}
448 @item Before a newline
449
450 @item Before the alternation operator @samp{\|}
451
452 @end enumerate
453
454
455 @samp{\*}, @samp{\+} and @samp{\?} are special at any point in a regular expression except:
456 @enumerate
457
458 @item At the beginning of a regular expression
459
460 @item After an open-group, signified by
461 @samp{\(}
462 @item After a newline
463
464 @item After the alternation operator @samp{\|}
465
466 @end enumerate
467
468
469 Intervals are specified by @samp{\@{} and @samp{\@}}.  Invalid intervals such as @samp{a\@{1z} are not accepted.
470
471 The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
472
473
474 @node posix-awk regular expression syntax
475 @subsection @samp{posix-awk} regular expression syntax
476
477
478 The character @samp{.} matches any single character except the null character.
479
480
481 @table @samp
482
483 @item +
484 indicates that the regular expression should match one or more occurrences of the previous atom or regexp.
485 @item ?
486 indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
487 @item \+
488 matches a @samp{+}
489 @item \?
490 matches a @samp{?}.
491 @end table
492
493
494 Bracket expressions are used to match ranges of characters.  Bracket expressions where the range is backward, for example @samp{[z-a]}, are invalid.  Within square brackets, @samp{\} can be used to quote the following character.  Character classes are supported; for example @samp{[[:digit:]]} will match a single decimal digit.
495
496 GNU extensions are not supported and so @samp{\w}, @samp{\W}, @samp{\<}, @samp{\>}, @samp{\b}, @samp{\B}, @samp{\`}, and @samp{\'} match @samp{w}, @samp{W}, @samp{<}, @samp{>}, @samp{b}, @samp{B}, @samp{`}, and @samp{'} respectively.
497
498 Grouping is performed with parentheses @samp{()}.  An unmatched @samp{)} matches just itself.  A backslash followed by a digit acts as a back-reference and matches the same thing as the previous grouped expression indicated by that number.  For example @samp{\2} matches the second group expression.  The order of group expressions is determined by the position of their opening parenthesis @samp{(}.
499
500 The alternation operator is @samp{|}.
501
502 The characters @samp{^} and @samp{$} always represent the beginning and end of a string respectively, except within square brackets.  Within brackets, @samp{^} can be used to invert the membership of the character class being specified.
503
504 @samp{*}, @samp{+} and @samp{?} are special at any point in a regular expression except the following places, where they are not allowed:
505 @enumerate
506
507 @item At the beginning of a regular expression
508
509 @item After an open-group, signified by
510 @samp{(}
511 @item After the alternation operator @samp{|}
512
513 @end enumerate
514
515
516 Intervals are specified by @samp{@{} and @samp{@}}.  Invalid intervals are treated as literals, for example @samp{a@{1} is treated as @samp{a\@{1}
517
518 The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
519
520
521 @node posix-basic regular expression syntax
522 @subsection @samp{posix-basic} regular expression syntax
523 This is a synonym for ed.
524 @node posix-egrep regular expression syntax
525 @subsection @samp{posix-egrep} regular expression syntax
526
527
528 The character @samp{.} matches any single character except newline.
529
530
531 @table @samp
532
533 @item +
534 indicates that the regular expression should match one or more occurrences of the previous atom or regexp.
535 @item ?
536 indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
537 @item \+
538 matches a @samp{+}
539 @item \?
540 matches a @samp{?}.
541 @end table
542
543
544 Bracket expressions are used to match ranges of characters.  Bracket expressions where the range is backward, for example @samp{[z-a]}, are ignored.  Within square brackets, @samp{\} is taken literally.  Character classes are supported; for example @samp{[[:digit:]]} will match a single decimal digit.  Non-matching lists @samp{[^@dots{}]} do not ever match newline.
545
546 GNU extensions are supported:
547 @enumerate
548
549 @item @samp{\w} matches a character within a word
550
551 @item @samp{\W} matches a character which is not within a word
552
553 @item @samp{\<} matches the beginning of a word
554
555 @item @samp{\>} matches the end of a word
556
557 @item @samp{\b} matches a word boundary
558
559 @item @samp{\B} matches characters which are not a word boundary
560
561 @item @samp{\`} matches the beginning of the whole input
562
563 @item @samp{\'} matches the end of the whole input
564
565 @end enumerate
566
567
568 Grouping is performed with parentheses @samp{()}.  A backslash followed by a digit acts as a back-reference and matches the same thing as the previous grouped expression indicated by that number.  For example @samp{\2} matches the second group expression.  The order of group expressions is determined by the position of their opening parenthesis @samp{(}.
569
570 The alternation operator is @samp{|}.
571
572 The characters @samp{^} and @samp{$} always represent the beginning and end of a string respectively, except within square brackets.  Within brackets, @samp{^} can be used to invert the membership of the character class being specified.
573
574 The characters @samp{*}, @samp{+} and @samp{?} are special anywhere in a regular expression.
575
576 Intervals are specified by @samp{@{} and @samp{@}}.  Invalid intervals are treated as literals, for example @samp{a@{1} is treated as @samp{a\@{1}
577
578 The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
579
580
581 @node posix-extended regular expression syntax
582 @subsection @samp{posix-extended} regular expression syntax
583
584
585 The character @samp{.} matches any single character except the null character.
586
587
588 @table @samp
589
590 @item +
591 indicates that the regular expression should match one or more occurrences of the previous atom or regexp.
592 @item ?
593 indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
594 @item \+
595 matches a @samp{+}
596 @item \?
597 matches a @samp{?}.
598 @end table
599
600
601 Bracket expressions are used to match ranges of characters.  Bracket expressions where the range is backward, for example @samp{[z-a]}, are invalid.  Within square brackets, @samp{\} is taken literally.  Character classes are supported; for example @samp{[[:digit:]]} will match a single decimal digit.
602
603 GNU extensions are supported:
604 @enumerate
605
606 @item @samp{\w} matches a character within a word
607
608 @item @samp{\W} matches a character which is not within a word
609
610 @item @samp{\<} matches the beginning of a word
611
612 @item @samp{\>} matches the end of a word
613
614 @item @samp{\b} matches a word boundary
615
616 @item @samp{\B} matches characters which are not a word boundary
617
618 @item @samp{\`} matches the beginning of the whole input
619
620 @item @samp{\'} matches the end of the whole input
621
622 @end enumerate
623
624
625 Grouping is performed with parentheses @samp{()}.  An unmatched @samp{)} matches just itself.  A backslash followed by a digit acts as a back-reference and matches the same thing as the previous grouped expression indicated by that number.  For example @samp{\2} matches the second group expression.  The order of group expressions is determined by the position of their opening parenthesis @samp{(}.
626
627 The alternation operator is @samp{|}.
628
629 The characters @samp{^} and @samp{$} always represent the beginning and end of a string respectively, except within square brackets.  Within brackets, @samp{^} can be used to invert the membership of the character class being specified.
630
631 @samp{*}, @samp{+} and @samp{?} are special at any point in a regular expression except the following places, where they are not allowed:
632 @enumerate
633
634 @item At the beginning of a regular expression
635
636 @item After an open-group, signified by
637 @samp{(}
638 @item After the alternation operator @samp{|}
639
640 @end enumerate
641
642
643 Intervals are specified by @samp{@{} and @samp{@}}.  Invalid intervals such as @samp{a@{1z} are not accepted.
644
645 The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
646