next up previous contents
Next: Extension Syntax Up: Regular Expressions Previous: Pattern Memory

Pattern Precedence

Pattern components have an order of precedence just as operators do. If you see the following pattern:


it's hard to tell if the pattern should be

The order of precedence is designed to solve problems like this. By consulting the Perl order of precedence table, you would see that quantifiers have a higher precedence than alternation. Therefore, the second interpretation is correct.

You can use parentheses to affect the order in which components are evaluated because they have the highest precedence. However, unless you use the extended syntax, you will be affecting the pattern memory.