Note that (?>X+) does not exactly match X++ at the inverse point. Since the regular expression mechanism inside the brackets has the ability to indent, so the regular expression mechanism always registers the return positions in the atomic group (but forgets them after closing the parenthesis), this may, of course, not be the case with the possessive quantifier. Example:
consider the line aaaabbbb
(?>a+)ab , since a++ab will fail, because the regular expression mechanism will not be able to go back when the bracket of the closed atomic group is closed.
but
(?>a+ab) will be successful, since return positions are always written inside the atomic group.
(?:a+|ab)+(?<!a)b will succeed, but (?>a+|ab)+(?<!a)b will fail because the bracket is closed between each repetition.
Conclusion: the exact synonym (?>X+) not X++ , but (?:X+){1}+
source share