English 中文(简体)
Java Regex - Possessive quantifiers
  • 时间:2024-12-22

Examples of Possessive Quantifiers


Previous Page Next Page  

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.No Construct & Matches
1 X?+

X, once or not at all.

2 X*+

X, zero or more times

3 X++

X, one or more times.

4 X{n}+

X, exactly n times.

5 X{n,}+

X, at least n times.

6 X{n,m}+

X, at least n but not more than m times

Advertisements