Quantifiers
A quantifier specifies how many times (or if) something
occurs. There are three quantifier characters and a syntax for
specifying quantities more explicitly. For example, (a|b)?c
matches ac
, bc
, and
c
, because the question mark
indicates zero or one instances of a pattern. Here are all the
quantifiers and their syntax:
?
Zero or one of a pattern.
*
Zero or more of a pattern.
+
One or more of a pattern.
{x}
The pattern must occur exactly
x
times. The pattern(a|b){3}
matchesaaa
andabb
, but notab
.{x,}
The pattern must occur at least
x
times. The pattern(a|b){3,}
matchesaaa
andaaaaaaaaa
, but notaa
.{x,y}
The pattern must occur at least
x
times, but no more thany
times. The pattern(a|b){2,5}
matchesaa
andaaa
, but notaaaaaa
.
Get XSLT, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.