Search code examples
qregularexpression

why precedence over disjunction


I have a question about operator precedence hierarchy, why "Because sequences have a higher precedence than disjunction, /the|any/ matches the or any but not thany or they"? I just couldn't understand why this result reflects "precedence over disjunction"?


Solution

  • If the disjunction operator had a higher precedence than grouping together each sequence of characters, than it could operate on the individual characters or subgroups. It could be interpreted as something like /the(e|an)y/