It goes on to say that it is just syntactic sugarThey are indeed syntactic sugar. But I prefer to write: /a++/ over /(?>a+)/. 2 special characters instead of 5.
As for the OPs question, the main use is performance - specially in cases of not matching. Using possessive quantifiers changes the meaning - unlike non-greedy matches, possessive quantifiers can change the matching/non-matching behaviour. That is, given a pattern, making quantifiers non-greedy (or making non-greedy quantifiers greedy) will not change the set of strings the pattern matches, but making quantifiers possessive can change the set (but only by reducing the set). But I would recommend using possessive quantifiers for that effect - that's just too subtle.
In reply to Re^2: When would I want to use possessive quantifiers?
by JavaFan
in thread When would I want to use possessive quantifiers?
by petdance
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |