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 precedence syntax

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 precedence example

\ Escape character
(), (?:), (?=), [] Parentheses and square brackets
*, +, ?, { n}, {n,}, {n,m} Qualifier
^, $, \any metacharacter, any character Anchor 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".