A pattern item may be
- a single character class, which matches any single character in the class;
- a single character class followed by '=*=', which matches 0 or more repetitions of characters in the class. These repetition items will always match the longest possible sequence;
- a single character class followed by '=+=', which matches 1 or more repetitions of characters in the class. These repetition items will always match the longest possible sequence;
- a single character class followed by '=-=', which also matches 0 or more repetitions of characters in the class. Unlike '=*=', these repetition items will always match the shortest possible sequence;
- a single character class followed by '=?=', 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);
%b_xy_
, 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.