正则表达式中的Quantifiers
?: Match an element zero or one time
例如:
colou?r:
color
或
colour
但不能是
colo2r
*: Match an element zero or more times
+: Match an element one or more times
{}: Match an element a specific number of times
可以自定义需要满足条件的次数:
{n}: exactly 满足 n 次
{n, m}: 至少满足 n 次,不能超过 m 次
{n,}: 至少满足 n 次
{,m}: 不能满足条件的超过 m 次
可以按照数组范围的概率来理解。
浙公网安备 33010602011771号