Why does this regex pattern not match?

This question already has an answer here:

  • Greedy vs. Reluctant vs. Possessive Quantifiers 7 answers
  • Can someone explain Possessive Quantifiers to me? (Regular Expressions) 1 answer

  • ++ 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.

    链接地址: http://www.djcxy.com/p/76902.html

    上一篇: 正则表达式(\ S +?)vs(\ S +))

    下一篇: 为什么这个正则表达式模式不匹配?