Like C and C++ operators, the Regular Expression syntax specifiers are processed in a specific order. The order of precedence for Basic Regular Expressions is described below, from highest to lowest priority. The specifiers in each category are also listed in order of precedence.
| Syntax Specifiers | Precedence |
|---|---|
| Collation-related bracket symbols | [==] [::] [..] |
| Special characters | \spec_char |
| Bracket expressions | [ ] |
| Subexpressions and backreferences | \(\) \n |
| Repetition | * \{m\} \{m,\} \{m,n\} |
| Concatenation | |
| Anchoring | ^ $ |