Regular expressions - operator precedence


  Translation results:

Regular Expression is a text pattern that includes ordinary characters (for example, letters between a and z) and special characters (called "metacharacters").

Regular expressions use a single string to describe and match a series of strings that match a certain syntax rule.

Regular expressions - operator precedencesyntax

Regular expressions are evaluated from left to right and follow an order of precedence, much like arithmetic expressions.

Operations with the same priority are performed from left to right, and operations with different priorities are performed from high to low.

Regular expressions - operator precedenceexample

\Escape character
(), (?:), (?=), []Parentheses and square brackets
*, +, ?, { n}, {n,}, {n,m}Qualifier
^, $, \any metacharacter, any characterAnchor points and sequences (ie: position and order)
|Replace," or "The
operator has higher precedence than the replacement operator, such that "m|food" matches "m" or "food". To match "mood" or "food", use parentheses to create a subexpression, resulting in "(m|f)ood".

Popular Recommendations

Home

Videos

Q&A