User Guide
114
Single-character regular expressions
This section describes the rules for creating regular expressions. You can use regular
expressions in the Search > Extended Find and Replace commands to match complex
string patterns.
The following rules govern one-character RegExp that match a single character:
• Special characters are: + * ? . [ ^ $ ( ) { | \
• Any character that is not a special character matches itself.
• Use the keyboard (Tab, Enter) to match whitespace characters.
• The asterisk (*) matches the specified characters throughout the entire
document.
• The carat (^) matches the beginning of the document.
• The dollar sign ($) matches the end of the document.
• A backslash (\) followed by any special character matches the literal character
itself, that is, the backslash escapes the special character.
• A period (.) matches any character, including newline. To match any character
except a newline, use [^#chr(13)##chr(10)#], which excludes the ASCII carriage
return and line feed codes.
• A set of characters enclosed in brackets ([]) is a one-character RE that matches
any of the characters in that set. For example, "[akm]" matches an "a", "k", or
"m". Note that if you want to include ] (closing square bracket) in square
brackets it must be the first character. Otherwise, it won't work even if you use
\].
• Any regular expression can be followed by one of the following suffixes: {m,n}
forces a match of m through n (inclusive) occurrences of the preceding regular
expression. The suffix {m,} forces a match of at least m occurrences of the
preceding regular expression. The syntax {,n} is not allowed.
• A range of characters can be indicated with a dash. For example, "[a-z]"
matches any lowercase letter. However, if the first character of the set is the
caret (^), the RegExp matches any character except those in the set. It does not
match the empty string. For 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.
• All regular expressions can be made case insensitive by substituting individual
characters with character sets, for example, [Nn][Ii][Cc][Kk].
Character classes
You can specify a character by using one of the POSIX character classes. You enclose
the character class name inside two square brackets, as in this Replace example:
"Allaire’s Web Site","[[:space:]]","*","ALL")
This code replaces all the spaces with *, producing this string:
Allaire’s*Web*Site