Regular expressions are calculated from left to right and follow priority order, which is very similar to the arithmetic expression.
The following table has a priority order of various regular expression operators from the highest to minimum:
Operator Description / Essential (), (? :), (? =), [] Brackets and middle brackets *, ,?, {N}, {n,}, {n, m} definition ^, $, / Anymetachacter, AnyCharacter Location Point and Sequence | Replacement
The priority of characters is higher than that of the replacement operator, and the alternative operator allows "M | Food" to match "M" or "Food". To match "Mood" or "Food", use parentheses to create sub-expressions to generate "(m | f) OOD."