Java Reference
In-Depth Information
Subexpression
Matches
Notes
{ m , n }
Quantifier for “from m to n repetitions”
See Replacing the Matched Text
Quantifier for " m or more repetitions”
{ m ,}
Quantifier for “exactly m repetitions”
See Program: Apache Logfile
Parsing
{ m }
{ , n }
Quantifier for 0 up to n repetitions
Quantifier for 0 or more repetitions
Short for {0,}
\*
Quantifier for 1 or more repetitions
Short for {1,} ; see Using regexes
in Java: Test for a Pattern
+
Quantifier for 0 or 1 repetitions (i.e.,
present exactly once, or not at all)
Short for {0,1}
?
Reluctant (non-greedy)
quantifiers
{ m , n }?
Reluctant quantifier for “from m to n repeti-
tions”
Reluctant quantifier for " m or more repeti-
tions”
{ m ,}?
{ , n }?
Reluctant quantifier for 0 up to n repetitions
Reluctant quantifier: 0 or more
\*?
Reluctant quantifier: 1 or more
See Program: Apache Logfile
Parsing
+?
Reluctant quantifier: 0 or 1 times
??
Possessive (very greedy)
quantifiers
{ m , n }+
Possessive quantifier for “from m to n repeti-
tions”
Possessive quantifier for " m or more repeti-
tions”
{ m ,}+
Search WWH ::




Custom Search