Quantifiers¶
.optional¶
Matches 0
or 1
of the proceeding expression.
Example
ExpressiveRegex()\
.optional.digit\
.toRegexString()
"\d?"
.zeroOrMore¶
Matches 0
or more
repetitions of the proceeding expression.
Example
ExpressiveRegex()\
.zeroOrMore.digit\
.toRegexString()
"\d*"
.zeroOrMoreLazy¶
Matches 0
or more
repetitions of the proceeding expression, but as few times as possible.
Example
ExpressiveRegex()\
.zeroOrMoreLazy.digit\
.toRegexString()
"\d*"
.oneOrMore¶
Matches 1
or more
repetitions of the proceeding expression.
Example
ExpressiveRegex()\
.oneOrMore.digit\
.toRegexString()
"\d+"
.oneOrMoreLazy¶
Matches 1
or more
repetitions of the proceeding expression, but as few times as possible.
Example
ExpressiveRegex()\
.oneOrMoreLazy.digit\
.toRegexString()
"\d+?"
.exactly(n)¶
Matches exactly n
repetitions of the proceeding expression.
Example
ExpressiveRegex()\
.exactly(4).digit\
.toRegexString()
"\d{4}"
.atLeast(n)¶
Matches at least n
repetitions of the proceeding expression.
If n
is 1
then is equivalente to .oneOrMore .
If n
is 0
then is equivalente to .zeroOrMore .
Example
ExpressiveRegex()\
.atLeast(4).digit\
.toRegexString()
"\d{4,}"
.uoTo(n)¶
Matches up to n
repetitions of the proceeding expression.
If n
is 1
then is equivalente to .optional .
Example
ExpressiveRegex()\
.uoTo(4).digit\
.toRegexString()
"\d{,4}"
.between(n,m)¶
Matches between n
and m
repetitions of the proceeding expression.
If n
is 0
and m
is 1
then is equivalente to .optional .
If n
is 0
and m
> 1
then is equivalente to .uoTo(m) .
Example
ExpressiveRegex()\
.between(2,4).digit\
.toRegexString()
"\d{2,4}"
.betweenLazy(n,m)¶
Matches between n
and m
repetitions of the proceeding expression, but as few times as possible.
Example
ExpressiveRegex()\
.between(2,4).digit\
.toRegexString()
"\d{2,4}?"