Like C and C++ operators, the Regular Expression (RE) syntax specifiers are processed in a specific order. The order of precedence 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 | [ ] |
| Grouping | ( ) |
| Repetition | * + ? {m} {m,} {m,n} |
| Concatenation | |
| Anchoring | ^ $ |
| Alternation | | |