Why does this regex pattern not match?
This question already has an answer here:
++
Matches between one and unlimited times, as many times as possible, without giving back - means, if you write .++
, it matches everything including the final b
. So the additional b
in your regex will never matched.
You could get around this, if you don't use possessive quantifiers or simply remove the b
from the matching class [^b]++b
- but I would suggest the first. Possessive quantifiers are almost everytime unneccessary.
下一篇: 为什么这个正则表达式模式不匹配?