Specifications

MeaningCharacter
The caret negates the character set if it occurs as the first character,
that is immediately after the opening square bracket. For example,
^
[abc] matches 'a' or 'b' or 'c', but [^abc] matches anything except
'a' or 'b' or 'c'.
The dash is used to indicate a range of characters, for example,
[W-Z] matches 'W' or 'X' or 'Y' or 'Z'.
-
Using the predefined character set abbreviations is more portable than using character ranges
across platforms and languages. For example, [0-9] matches a digit in Western alphabets but
\d matches a digit in any alphabet.
Note that in most regexp literature sets of characters are called "character classes".
Quantifiers
By default an expression is automatically quantified by {1,1}, i.e. it should occur exactly once. In
the following list E stands for any expression. An expression is a character or an abbreviation
for a set of characters or a set of characters in square brackets or any parenthesized expression.
MeaningQuantifier
Matches zero or one occurrence of E. This quantifier means "the
previous expression is optional" since it will match whether or not the
E?
expression occurs in the string. It is the same as E{0,1}. For example
dents? will match 'dent' and 'dents'.
Matches one or more occurrences of E. This is the same as E{1,}. For
example, 0+ will match '0', '00', '000', etc.
E+
Matches zero or more occurrences of E. This is the same as E{0,}. The
* quantifier is often used by mistake. Since it matches zero or more
E*
occurrences it will match no occurrences at all. For example if we want
to match strings that end in whitespace and use the regexp \s*$ we
would get a match on every string. This is because we have said find
zero or more whitespace followed by the end of string, so even strings
that don't end in whitespace will match. The regexp we want in this
case is \s+$ to match strings that have at least one whitespace at the
end.
Matches exactly n occurrences of E. This is the same as repeating the
expression n times. For example, x{5} is the same as xxxxx. It is also
the same as E{n,n}, e.g. x{5,5}.
E{n}
Matches at least n occurrences of E.E{n,}
Matches at most m occurrences of E. This is the same as E{0,m}.
E{,m}
Matches at least n occurrences of E and at most m occurrences of E.E{n,m}
199
Enfocus Switch 10