Home > Articles > Web Services > XML

  • Print
  • + Share This
From the author of


Because of the dearth of operators for regular expressions, precedence is easy to remember, and what one would logically expect. The following list itemizes the operators from highest to lowest precedence:

  • Quantifiers ('?', '*', '+', and '{n,m}')

  • Concatenation

  • Alternatives ('|')

Of course, grouping with '(' and ')' overrides precedence, as in almost any programming language.

For clarity, here are a few precedence examples:

Regular Expression


Matching Strings


Either the character 'X' or the sequence 'ab' followed by an optional 'c'.





The sequence 'abc' (with one or more 'b') or the sequence 'def' with one or more 'e').




'Xbc' or 'abc', 'a' being optional on the latter string.





'ab', or 1 or 2 'c', or 'de'.






'a' followed by zero or one 'xyz'.



  • + Share This
  • 🔖 Save To Your Account