What is double plus in regular expressions?

后端 未结 2 1258
名媛妹妹
名媛妹妹 2020-12-14 15:21

I have been seeing this in some PHP script:

[a-zA-Z0-9_]++

What does the double plus mean?

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-14 16:02

    That's a Possessive Quantifier.

    It basically means that if the regex engine fails matching later, it will not go back and try to undo the matches it made here. In most cases, it allows the engine to fail much faster, and can give you some control where you need it - which is very rare for most uses.

提交回复
热议问题