regular expressions

A regular expression (RE) is a string representing a set of strings.

Each character in the string usually represents itself, but there are some special characters:

*asteriskany string with zero or more chars
?question markany single char
[charset]square bracketsa single char in the given set
\backslashtreats literally the special char immediately following

A charset is a string defining a set of characters.

A well formed charset is composed by one or more items, separated by ',' (comma). If no operator is specified the resulting charset is built by adding items (union).

Each character in the charset definition usually represents itself, but there are some special characters.

,commaitem separator
!bangnot operator, only at item beginning: add the complementary charset
-dashminus operator, only at item beginning: subtract characters from set
-dashrange operator, between two chars
\backslashtreats literally the special char immediately following

An expression of regular expressions (REE) is an expression whose terms are regular expressions, with the following operators, from higher priority to lower:

()bracketscontains a subexpression, nesting allowed
!bangNOT
&ampersandAND
|pipeOR
\backslashtreats literally the special char immediately following

Examples:

REEmeaning
a*any string starting with 'a'
*zany string ending with 'z'
a*m*zany string starting with 'a', containing at least one 'm', ending with 'z'
???any three characters long string
[AEIOU]an uppercase vowel
[A-Z,-AEIOU]an uppercase consonant
[!AEIOU]any character except uppercase vowels
[0123456789]a decimal digit, same as [0-9]
[0-9A-Fa-f]a hexadecimal digit, same as [0-9,A-F,a-f]
[A-Z,a-z]an alphabetic character, uppercase or lowercase
!*j*any string NOT containing a 'j'
?*@?*.?*a well formed email address
s??|(*m*&?????)a three characters long string starting with 's' OR a five characters long string containing a 'm'