Tools.h++ Class Reference

Table Of Contents
1.5 A set of characters enclosed in brackets ([]) is a one-character RE that matches any of the
characters in that set. E.g., "[akm]" matches either an "a", "k", or "m". A range of
characters can be indicated with a dash. E.g., "[a-z]" matches any lower-case letter.
However, if the first character of the set is the caret (^), then the RE matches any character
except those in the set. It does not match the empty string. Example: [^akm] matches any
character except "a", "k", or "m". The caret loses its special meaning if it is not the first
character of the set.
The following rules can be used to build a multicharacter RE.
2.1 A one-character RE followed by an asterisk (*) matches zero or more occurrences of the
RE. Hence, [a-z]* matches zero or more lower-case characters.
2.2 A one-character RE followed by a plus (+) matches one or more occurrences of the RE.
Hence, [a-z]+ matches one or more lower-case characters.
2.3 A question mark (?) is an optional element. The preceeding RE can occur zero or once in
the string -- no more. E.g. xy?z matches either xyz or xz.
2.4 The concatenation of REs is a RE that matches the corresponding concatenation of strings.
E.g., [A-Z][a-z]* matches any capitalized word.
Finally, the entire regular expression can be anchored to match only the beginning or end of a
line:
3.1 If the caret (^) is at the beginning of the RE, then the matched string must be at the
beginning of a line.
3.2 If the dollar sign ($) is at the end of the RE, then the matched string must be at the end of
the line.
The following escape codes can be used to match control characters:
\b backspace
\e ESC (escape)
\f formfeed
\n newline
\r carriage return
\t tab
\xddd the literal hex number 0xdd
\ddd the literal octal number ddd
\^C Control code. E.g. \^D is "control-D"
Persistence
None