A pattern item may be
*
',
which matches 0 or more repetitions of characters in the class.
These repetition items will always match the longest possible sequence;
+
',
which matches 1 or more repetitions of characters in the class.
These repetition items will always match the longest possible sequence;
-
',
which also matches 0 or more repetitions of characters in the class.
Unlike '*
',
these repetition items will always match the shortest possible sequence;
?
',
which matches 0 or 1 occurrence of a character in the class;
%n
, for n between 1 and 9;
such item matches a substring equal to the n-th captured string
(see below);
%bxy
, where x and y are two distinct characters;
such item matches strings that start with x, end with y,
and where the x and y are balanced.
This means that, if one reads the string from left to right,
counting +1 for an x and -1 for a y,
the ending y is the first y where the count reaches 0.
For instance, the item %b()
matches expressions with
balanced parentheses.