Patterns in flex are written using an extended set of regular expressions. Here are some of them:
match the character `x'
any character (byte) except newline
a "character class"; in this example, the pattern matches either an `x', a `y', or a `z'
a "character class" with a range in it; matches an `a', a `b', any letter from `j' through `o', or a `Z'
a "negated character class", i.e., any character but those in the class. In this example, any character except an uppercase letter.
any character except an uppercase letter or a newline
zero or more r's, where r is any regular expression
one or more r's
zero or one r's (that is, "an optional r")
anywhere from two to five r's
two or more r's
exactly 4 r's
the literal string: `[xyz]"foo'
if x is an `a', `b', `f', `n', `r', `t', or `v', then the ANSI-C interpretation of \x. Otherwise, a literal `x' (used to escape operators such as `*')
a NUL character (ASCII code 0)
the character with octal value 123
the character with hexadecimal value 2a
match an r; parentheses are used to override precedence
the regular expression r followed by the regular expression s; called "concatenation"
either an r or an s
an r, but only at the beginning of a line (i.e., which just starting to scan, or right after a newline has been scanned).
an r, but only at the end of a line (i.e., just before a newline).
an r, but only in start condition s.
same, but in any of start conditions s1, s2, or s3
an r in any start condition, even an exclusive one.
an end-of-file
an end-of-file when in start condition s1 or s2
Note that inside of a character class, all regular expression operators lose their special meaning except escape ('\') and the character class operators, '-', ']', and, at the beginning of the class, '^'.

The regular expressions listed above are grouped according to precedence, from highest precedence at the top to lowest at the bottom.