Export (0) Print
Expand All
1 out of 3 rated this helpful - Rate this topic

Order of Precedence 

A regular expression is evaluated from left to right and follows an order of precedence, much like an arithmetic expression.

Operators

The following table illustrates, from highest to lowest, the order of precedence of the various regular expression operators:

Operator(s) Description

\

Escape

(), (?:), (?=), []

Parentheses and Brackets

*, +, ?, {n}, {n,}, {n,m}

Quantifiers

^, $, \anymetacharacter, anycharacter

Anchors and Sequences

|

Alternation

Characters have higher precedence than the alternation operator, which allows 'm|food' to match "m" or "food". To match "mood" or "food", use parentheses to create a subexpression, which results in '(m|f)ood'.

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.