2 * awk regular expression syntax::
3 * egrep regular expression syntax::
4 * ed regular expression syntax::
5 * emacs regular expression syntax::
6 * gnu-awk regular expression syntax::
7 * grep regular expression syntax::
8 * posix-awk regular expression syntax::
9 * posix-basic regular expression syntax::
10 * posix-egrep regular expression syntax::
11 * posix-extended regular expression syntax::
12 * posix-minimal-basic regular expression syntax::
13 * sed regular expression syntax::
16 @node awk regular expression syntax
17 @subsection @samp{awk} regular expression syntax
20 The character @samp{.} matches any single character except the null character.
26 indicates that the regular expression should match one or more occurrences of the previous atom or regexp.
28 indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
36 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 not supported, so for example you would need to use @samp{[0-9]} instead of @samp{[[:digit:]]}.
38 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.
40 Grouping is performed with parentheses @samp{()}. An unmatched @samp{)} matches just itself. A backslash followed by a digit matches that digit.
42 The alternation operator is @samp{|}.
44 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.
46 @samp{*}, @samp{+} and @samp{?} are special at any point in a regular expression except:
49 @item At the beginning of a regular expression
51 @item After an open-group, signified by
53 @item After the alternation operator @samp{|}
60 The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
63 @node egrep regular expression syntax
64 @subsection @samp{egrep} regular expression syntax
67 The character @samp{.} matches any single character except newline.
73 indicates that the regular expression should match one or more occurrences of the previous atom or regexp.
75 indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
83 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.
85 GNU extensions are supported:
88 @item @samp{\w} matches a character within a word
90 @item @samp{\W} matches a character which is not within a word
92 @item @samp{\<} matches the beginning of a word
94 @item @samp{\>} matches the end of a word
96 @item @samp{\b} matches a word boundary
98 @item @samp{\B} matches characters which are not a word boundary
100 @item @samp{\`} matches the beginning of the whole input
102 @item @samp{\'} matches the end of the whole input
107 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{(}.
109 The alternation operator is @samp{|}.
111 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.
113 The characters @samp{*}, @samp{+} and @samp{?} are special anywhere in a regular expression.
117 The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
120 @node ed regular expression syntax
121 @subsection @samp{ed} regular expression syntax
124 The character @samp{.} matches any single character except the null character.
130 indicates that the regular expression should match one or more occurrences of the previous atom or regexp.
132 indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
138 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.
140 GNU extensions are supported:
143 @item @samp{\w} matches a character within a word
145 @item @samp{\W} matches a character which is not within a word
147 @item @samp{\<} matches the beginning of a word
149 @item @samp{\>} matches the end of a word
151 @item @samp{\b} matches a word boundary
153 @item @samp{\B} matches characters which are not a word boundary
155 @item @samp{\`} matches the beginning of the whole input
157 @item @samp{\'} matches the end of the whole input
162 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{\(}.
164 The alternation operator is @samp{\|}.
166 The character @samp{^} only represents the beginning of a string when it appears:
170 At the beginning of a regular expression
172 @item After an open-group, signified by
175 @item After the alternation operator @samp{\|}
180 The character @samp{$} only represents the end of a string when it appears:
183 @item At the end of a regular expression
185 @item Before an close-group, signified by
187 @item Before the alternation operator @samp{\|}
192 @samp{\*}, @samp{\+} and @samp{\?} are special at any point in a regular expression except:
195 @item At the beginning of a regular expression
197 @item After an open-group, signified by
199 @item After the alternation operator @samp{\|}
204 Intervals are specified by @samp{\@{} and @samp{\@}}. Invalid intervals such as @samp{a\@{1z} are not accepted.
206 The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
209 @node emacs regular expression syntax
210 @subsection @samp{emacs} regular expression syntax
213 The character @samp{.} matches any single character except newline.
219 indicates that the regular expression should match one or more occurrences of the previous atom or regexp.
221 indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
229 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:]]}.
231 GNU extensions are supported:
234 @item @samp{\w} matches a character within a word
236 @item @samp{\W} matches a character which is not within a word
238 @item @samp{\<} matches the beginning of a word
240 @item @samp{\>} matches the end of a word
242 @item @samp{\b} matches a word boundary
244 @item @samp{\B} matches characters which are not a word boundary
246 @item @samp{\`} matches the beginning of the whole input
248 @item @samp{\'} matches the end of the whole input
253 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{\(}.
255 The alternation operator is @samp{\|}.
257 The character @samp{^} only represents the beginning of a string when it appears:
261 At the beginning of a regular expression
263 @item After an open-group, signified by
266 @item After the alternation operator @samp{\|}
271 The character @samp{$} only represents the end of a string when it appears:
274 @item At the end of a regular expression
276 @item Before an close-group, signified by
278 @item Before the alternation operator @samp{\|}
283 @samp{*}, @samp{+} and @samp{?} are special at any point in a regular expression except:
286 @item At the beginning of a regular expression
288 @item After an open-group, signified by
290 @item After the alternation operator @samp{\|}
297 The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
300 @node gnu-awk regular expression syntax
301 @subsection @samp{gnu-awk} regular expression syntax
304 The character @samp{.} matches any single character.
310 indicates that the regular expression should match one or more occurrences of the previous atom or regexp.
312 indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
320 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.
322 GNU extensions are supported:
325 @item @samp{\w} matches a character within a word
327 @item @samp{\W} matches a character which is not within a word
329 @item @samp{\<} matches the beginning of a word
331 @item @samp{\>} matches the end of a word
333 @item @samp{\b} matches a word boundary
335 @item @samp{\B} matches characters which are not a word boundary
337 @item @samp{\`} matches the beginning of the whole input
339 @item @samp{\'} matches the end of the whole input
344 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{(}.
346 The alternation operator is @samp{|}.
348 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.
350 @samp{*}, @samp{+} and @samp{?} are special at any point in a regular expression except:
353 @item At the beginning of a regular expression
355 @item After an open-group, signified by
357 @item After the alternation operator @samp{|}
364 The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
367 @node grep regular expression syntax
368 @subsection @samp{grep} regular expression syntax
371 The character @samp{.} matches any single character except newline.
377 indicates that the regular expression should match one or more occurrences of the previous atom or regexp.
379 indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
385 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.
387 GNU extensions are supported:
390 @item @samp{\w} matches a character within a word
392 @item @samp{\W} matches a character which is not within a word
394 @item @samp{\<} matches the beginning of a word
396 @item @samp{\>} matches the end of a word
398 @item @samp{\b} matches a word boundary
400 @item @samp{\B} matches characters which are not a word boundary
402 @item @samp{\`} matches the beginning of the whole input
404 @item @samp{\'} matches the end of the whole input
409 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{\(}.
411 The alternation operator is @samp{\|}.
413 The character @samp{^} only represents the beginning of a string when it appears:
417 At the beginning of a regular expression
419 @item After an open-group, signified by
422 @item After a newline
424 @item After the alternation operator @samp{\|}
429 The character @samp{$} only represents the end of a string when it appears:
432 @item At the end of a regular expression
434 @item Before an close-group, signified by
436 @item Before a newline
438 @item Before the alternation operator @samp{\|}
443 @samp{\*}, @samp{\+} and @samp{\?} are special at any point in a regular expression except:
446 @item At the beginning of a regular expression
448 @item After an open-group, signified by
450 @item After a newline
452 @item After the alternation operator @samp{\|}
457 Intervals are specified by @samp{\@{} and @samp{\@}}. Invalid intervals such as @samp{a\@{1z} are not accepted.
459 The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
462 @node posix-awk regular expression syntax
463 @subsection @samp{posix-awk} regular expression syntax
466 The character @samp{.} matches any single character except the null character.
472 indicates that the regular expression should match one or more occurrences of the previous atom or regexp.
474 indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
482 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.
484 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.
486 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{(}.
488 The alternation operator is @samp{|}.
490 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.
492 @samp{*}, @samp{+} and @samp{?} are special at any point in a regular expression except the following places, where they are illegal:
495 @item At the beginning of a regular expression
497 @item After an open-group, signified by
499 @item After the alternation operator @samp{|}
504 Intervals are specified by @samp{@{} and @samp{@}}. Invalid intervals such as @samp{a@{1z} are not accepted.
506 The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
509 @node posix-basic regular expression syntax
510 @subsection @samp{posix-basic} regular expression syntax
511 This is a synonym for ed.
512 @node posix-egrep regular expression syntax
513 @subsection @samp{posix-egrep} regular expression syntax
516 The character @samp{.} matches any single character except newline.
522 indicates that the regular expression should match one or more occurrences of the previous atom or regexp.
524 indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
532 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.
534 GNU extensions are supported:
537 @item @samp{\w} matches a character within a word
539 @item @samp{\W} matches a character which is not within a word
541 @item @samp{\<} matches the beginning of a word
543 @item @samp{\>} matches the end of a word
545 @item @samp{\b} matches a word boundary
547 @item @samp{\B} matches characters which are not a word boundary
549 @item @samp{\`} matches the beginning of the whole input
551 @item @samp{\'} matches the end of the whole input
556 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{(}.
558 The alternation operator is @samp{|}.
560 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.
562 The characters @samp{*}, @samp{+} and @samp{?} are special anywhere in a regular expression.
564 Intervals are specified by @samp{@{} and @samp{@}}. Invalid intervals are treated as literals, for example @samp{a@{1} is treated as @samp{a\@{1}
566 The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
569 @node posix-extended regular expression syntax
570 @subsection @samp{posix-extended} regular expression syntax
573 The character @samp{.} matches any single character except the null character.
579 indicates that the regular expression should match one or more occurrences of the previous atom or regexp.
581 indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
589 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.
591 GNU extensions are supported:
594 @item @samp{\w} matches a character within a word
596 @item @samp{\W} matches a character which is not within a word
598 @item @samp{\<} matches the beginning of a word
600 @item @samp{\>} matches the end of a word
602 @item @samp{\b} matches a word boundary
604 @item @samp{\B} matches characters which are not a word boundary
606 @item @samp{\`} matches the beginning of the whole input
608 @item @samp{\'} matches the end of the whole input
613 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{(}.
615 The alternation operator is @samp{|}.
617 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.
619 @samp{*}, @samp{+} and @samp{?} are special at any point in a regular expression except the following places, where they are illegal:
622 @item At the beginning of a regular expression
624 @item After an open-group, signified by
626 @item After the alternation operator @samp{|}
631 Intervals are specified by @samp{@{} and @samp{@}}. Invalid intervals such as @samp{a@{1z} are not accepted.
633 The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
636 @node posix-minimal-basic regular expression syntax
637 @subsection @samp{posix-minimal-basic} regular expression syntax
640 The character @samp{.} matches any single character except the null character.
644 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.
646 GNU extensions are supported:
649 @item @samp{\w} matches a character within a word
651 @item @samp{\W} matches a character which is not within a word
653 @item @samp{\<} matches the beginning of a word
655 @item @samp{\>} matches the end of a word
657 @item @samp{\b} matches a word boundary
659 @item @samp{\B} matches characters which are not a word boundary
661 @item @samp{\`} matches the beginning of the whole input
663 @item @samp{\'} matches the end of the whole input
668 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{\(}.
672 The character @samp{^} only represents the beginning of a string when it appears:
676 At the beginning of a regular expression
678 @item After an open-group, signified by
684 The character @samp{$} only represents the end of a string when it appears:
687 @item At the end of a regular expression
689 @item Before an close-group, signified by
696 Intervals are specified by @samp{\@{} and @samp{\@}}. Invalid intervals such as @samp{a\@{1z} are not accepted.
698 The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
701 @node sed regular expression syntax
702 @subsection @samp{sed} regular expression syntax
703 This is a synonym for ed.