find: grep regular expression syntax
1
1 8.5.6 'grep' regular expression syntax
1 --------------------------------------
1
1 The character '.' matches any single character.
1
1 '\+'
1 indicates that the regular expression should match one or more
1 occurrences of the previous atom or regexp.
1 '\?'
1 indicates that the regular expression should match zero or one
1 occurrence of the previous atom or regexp.
1 '+ and ?'
1 match themselves.
1
1 Bracket expressions are used to match ranges of characters. Bracket
1 expressions where the range is backward, for example '[z-a]', are
1 invalid. Within square brackets, '\' is taken literally. Character
1 classes are supported; for example '[[:digit:]]' will match a single
1 decimal digit.
1
1 GNU extensions are supported:
1
1 1. '\w' matches a character within a word
1
1 2. '\W' matches a character which is not within a word
1
1 3. '\<' matches the beginning of a word
1
1 4. '\>' matches the end of a word
1
1 5. '\b' matches a word boundary
1
1 6. '\B' matches characters which are not a word boundary
1
1 7. '\`' matches the beginning of the whole input
1
1 8. '\'' matches the end of the whole input
1
1 Grouping is performed with backslashes followed by parentheses '\(',
1 '\)'. A backslash followed by a digit acts as a back-reference and
1 matches the same thing as the previous grouped expression indicated by
1 that number. For example '\2' matches the second group expression. The
1 order of group expressions is determined by the position of their
1 opening parenthesis '\('.
1
1 The alternation operator is '\|'.
1
1 The character '^' only represents the beginning of a string when it
1 appears:
1
1 1. At the beginning of a regular expression
1
1 2. After an open-group, signified by '\('
1
1 3. After a newline
1
1 4. After the alternation operator '\|'
1
1 The character '$' only represents the end of a string when it
1 appears:
1
1 1. At the end of a regular expression
1
1 2. Before a close-group, signified by '\)'
1 3. Before a newline
1
1 4. Before the alternation operator '\|'
1
1 '\*', '\+' and '\?' are special at any point in a regular expression
1 except:
1
1 1. At the beginning of a regular expression
1
1 2. After an open-group, signified by '\('
1 3. After a newline
1
1 4. After the alternation operator '\|'
1
1 Intervals are specified by '\{' and '\}'. Invalid intervals such as
1 'a\{1z' are not accepted.
1
1 The longest possible match is returned; this applies to the regular
1 expression as a whole and (subject to this constraint) to subexpressions
1 within groups.
1