To use regular expressions, be sure that the option ( )Reg-Exp is selected in the Search/Replace dialog box.

Many characters have special meaning in the search string of regular expressions:

^ (caret)
Matches the beginning of a line (when it is the first character in a regular expression)
$
Matches the end of a line (when it is the last character in a regular expression).
. (period)
Simple wildcard that matches any character.
Matches zero or more occurrences of the preceding character (or list).
+
Matches one or more occurrences of the preceding character (or list).
?
Matches zero or one occurrences of the preceding character (or list). In other words, the preceding character is optional.

Examples of Using Regular Expressions

o.e
Matches any text containing “o”, followed by any character, followed by “e”. Will match the word “one” and the “ome” in the word “some”.
^o.e
Matches the same strings, but only if they appear at the beginning of a line. Will match the word “one” at the beginning of a line. Does NOT match “some”.
o.e$
Matches the same strings, but only if they appear at the end of a line. Will match the word “one” and the “ome” in the word “some” if they occur at the end of a line. Does NOT match the word “something”.
^$
Matches only a completely blank line.
^\s*$
Matches a blank line that might contain just spaces.
an*d
Matches any text containing “a”, followed by zero or more occurrences of “n”, followed by a “d”. Will match the “ad” in the word “add” and the word “and”.
an+e
Matches any text containing “a”, followed by one or more occurrences of “n”, followed by an “e”. Will match the “ane” in the word “cane” and the “anne” in the word “banned”.
an?e
Matches any text containing “a”, followed by zero or one occurrences of “n”, followed by an “e”. Will match the “ae” in the word “Caesar”, the “ane” in the word “cane”, but NOT the word “banned

Think of “*” as indicating that one or more occurrences of the previous character are “optional”. Notice that ann*e is identical to an+e


A list of characters within square brackets [ and ] matches any one character in that list. A range of characters can be abbreviated using a hyphen “ - ”. However, when the first character in the list is a “ ^ ” (caret) or “ ~ ” (tilda), the list matches any character, except those in the list.

[abc]d
Matches any text containing “a”, “b” or “c”, followed by “d”
[a-z]
Matches all lowercase letters
[z-a]
A range may also be specified in reverse order
[A-Za-z]
Matches all letters, upper or lowercase.
[A-Z][a-z]*
Matches all words beginning with one capital letter. (It matches an upper case letter followed by zero or more lower case letters.) E.g., it matches “Hello” and “I”, but not “ABC”.
[A-Z]+
Matches all capitalized words. E.g., it matches “I” and “ABC”, but not “Hello”.
[^a]
Matches any character, except for “a”
[^a-z]
Matches any character, except for a lowercase letter.
[~a-z]
Matches any character, except for a lowercase letter. [~ is equivalent to [^.
[^0-9]
Matches any character, except for a digit
\[
Matches the [ character
\\
Matches the \ character

The [ ]Case search option is applicable to regular expressions, but not within bracketed lists. Therefore, “hi” will match “HI”, “Hi”, etc., and the expression [a-z]i will match “hi” and “hI”, but not “Hi”. There is little reason to ever select the [ ] Case option — you could use the expression [h][i] to search for the lower case word “hi”.

A “\” followed by any character (except a digit or letter), simply matches that character. This allows searching for those characters which are used as special symbols in regular expressions. Although we recommend using the “\” in front of any special symbols you need to search in the text, the “\” is not needed when there is no possibility of confusion. For example, the characters {, }, |, * and + are not special within the square brackets. The $ is only special at the very end of the expression. Even the hyphen “-” is not special immediately following [ or preceding ] or outside of square brackets.

These characters are special symbols in regular expressions, and therefore must be preceded by “\” in order to search for them in the text:

^ $ . * + ? - ~ \ | [ ] { }

The syntax allows exceptions where the “\” is not needed, but in those cases the “\” does not hurt either, and we recommend using it in front of all non-alphanumeric characters within search strings. In the replacement string, only the two characters “\” and “&” are special symbols.

Related Resources