Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Order of Precedence 

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


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

Operator(s) Description



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

Parentheses and Brackets

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


^, $, \anymetacharacter, anycharacter

Anchors and Sequences



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

Community Additions

© 2015 Microsoft