An quantifier in a regular expression may be greedy (the default), reluctant, or possesive. A possesive quantifier does this:
An quantifier is made possessive by appending a plus sign.
X++ matches X one or more times,
and never gives up what it has matched.
For example, the expression
does match the string
X++ part of the expression eats up all the X's leaving the Z
to be matched by the rest of the expression.
However, the expression does not match the string
X++ eats the entire expression, and does not give up
the last X for the code
[A-Z]+ to match.
Is the entire string
matched by the regular expression
(Note: If you try this in the applet, remember that the applet finds substrings that match the regular expression. When the entire string matches the expression, "Group 0" and "String" will be identical.)