Next: , Previous: Reporting Bugs, Up: Top


Appendix A Extended regular expressions

The only difference between basic and extended regular expressions is in the behavior of a few characters: ‘?’, ‘+’, parentheses, and braces (‘{}’). While basic regular expressions require these to be escaped if you want them to behave as special characters, when using extended regular expressions you must escape them if you want them to match a literal character.

Examples:

abc?
becomes ‘abc\?’ when using extended regular expressions. It matches the literal string ‘abc?’.
c\+
becomes ‘c+’ when using extended regular expressions. It matches one or more ‘c’s.
a\{3,\}
becomes ‘a{3,}’ when using extended regular expressions. It matches three or more ‘a’s.
\(abc\)\{2,3\}
becomes ‘(abc){2,3}’ when using extended regular expressions. It matches either ‘abcabc’ or ‘abcabcabc’.
\(abc*\)\1
becomes ‘(abc*)\1’ when using extended regular expressions. Backreferences must still be escaped when using extended regular expressions.