Examples of Possessive Quantifiers

A possessive quantifier is similar to greedy quantifier. It indicates the engine to start by checking the entire string.It is different in the sense if it doesn’t work, if match failed and there is no looking back. Following are various examples of Possessive Quantifiers using regular expression in java.

Sr.NoConstruct & Matches
1X?+X, once or not at all.
2X*+X, zero or more times
3X++X, one or more times.
4X{n}+X, exactly n times.
5X{n,}+X, at least n times.
6X{n,m}+X, at least n but not more than m times

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *