Latest web development tutorials

Regular Expressions - operator precedence

Regular expressions are calculated from left to right, and follow the order of precedence, which is very similar to an arithmetic expression.

The same priority operation from left to right, the first operation of different priorities from high to low. The following table from highest to lowest priority order illustrates the various regular expression operators:

运算符 描述
\ 转义符
(), (?:), (?=), [] 圆括号和方括号
*, +, ?, {n}, {n,}, {n,m} 限定符
^, $, \任何元字符、任何字符 定位点和序列(即:位置和顺序)
| 替换,"或"操作