Derived CompositionsΒΆ

Elementary compositions enable the definition of more complex and more practical operations. A fixed number of concatenations of the same DFA may be manually written as:

RRRRRRRR

which matches if and only if there are eight adjacent lexemes matched by R. The shorthand for n repeated concatenations is

R{n}

With n being an integer greater or equal zero, the expression matches exactly n concatenations of lexemes matched by R.

R{n,m}

With n and m being integers greater or equal zero, the expression matches n to m (including m) concatenations of lexemes matched by R. It is a shorthand for the union of all R{i} with i iterating from n to m.

In general, a restriction on the number of repetitions is accomplished with ranges in { and } brackets. In practical applications, repetitions are often restricted with respect to their number. While the Kleene closure also matches the lexeme of zero length, the Kleene plus operation requires at least one repetition to match.

R+

The Kleene plus operation. It matches an arbitrary number of repetitions of what is matched by R but not zero repetitions. It is a shorthand for the concatenation of R and R*.

The minimum number of repetitions can also be restricted by integers greater than one.

R{n,}

With n being an integer greater or equal zero, matches an arbitrary number of repetitions of what is matched by R but not less than n number of repetitions. It is a shorthand for the concatenation of R{n} and R*.

Zero or one repetition are called optional expressions and their syntax is the ? suffix.

R?

Matches zero or one occurrence of what matches R. It is a shortand for the union of \Nothing and R.