Regular expressions

Choice expression

If e and f are regular‑expressions , so is e | f , a re-choice expression, that matches e or f .

Catenation expression

If e and f are regular‑expressions , so is e f , a catenation expression, that matches e followed by f .

Repetition expressions

If e is a regular‑expression , so are e * , e + and e ? . Expression e * matches 0...N occurrences of e , e + matches 1...N occurrences of e , and e ? matches 0...1 occurrences of e .

Primary expressions

Grouping expression

If e is a regular‑expression , so is ( e ) , a grouping expression.

Escape sequences

The following escape sequences start with a backslash character.

\x or \X followed by a hexadecimal digit sequence c matches a Unicode character whose code point is equal to c .

\d or \D followed by a decimal digit sequence c matches a Unicode character whose code point is equal to c .

\ followed by an octal digit sequence c matches a Unicode character whose code point is equal to c .

\u followed by four hexadecimal digits c matches a Unicode character whose code point is equal to c .

\U followed by eight hexadecimal digits c matches a Unicode character whose code point is equal to c .

Escape Value
\a \u0007
\b \u0008
\f \u000c
\n \u000a
\r \u000d
\t \u0009
\v \u000b

Any other character following the backslash character matches that character literally.

Character class

Single characters or character ranges like a-z inside square brackets form a character class .

A character class matches any single input character from the set of character contained by the class.

If the first character that follows the left square bracket is a caret ( ^ ), the class matches all but the listed characters and ranges following the caret.

Dot

The . character matches any single character except newline.

Expression reference

A regular expression in an expression‑file may refer to preceding expressions by name by enclosing the expression‑name inside braces. This forms an expression‑reference .

Similarly a regular expression in a lexer‑file may refer to expressions contained by imported expression files by name by enclosing the expression‑name inside braces.

Other characters

Any other character matches current input character literally.