3.6 Basic vs Extended Regular Expressions ¶
Basic regular expressions differ from extended regular expressions
in the following ways:
- The characters ‘?’, ‘+’,
‘{’, ‘|’, ‘(’, and ‘)’ lose their special meaning;
instead use the backslashed versions ‘\?’, ‘\+’, ‘\{’,
‘\|’, ‘\(’, and ‘\)’. Also, a backslash is needed
before an interval expression’s closing ‘}’.
- An unmatched ‘\)’ is invalid.
- If an unescaped ‘^’ appears neither first, nor directly after
‘\(’ or ‘\|’, it is treated like an ordinary character and
is not an anchor.
- If an unescaped ‘$’ appears neither last, nor directly before
‘\|’ or ‘\)’, it is treated like an ordinary character and
is not an anchor.
- If an unescaped ‘*’ appears first, or appears directly after
‘\(’ or ‘\|’ or anchoring ‘^’, it is treated like an
ordinary character and is not a repetition operator.