Javaregex 简明教程

Examples of Possessive Quantifiers

独占量词类似于贪婪量词。它指示引擎从检查整个字符串开始。如果不行,则它有不同的含义,如果匹配失败,并且没有回顾。以下是用 Java 中正则表达式使用独占量词的各种示例。

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