
326
Part II
Designing and Crafting Basic Pages
Matching character ranges
Beyond single characters, or repetitions of single characters, regular expressions incorporate the
capability of finding or excluding ranges of characters. This feature is particularly useful when
you’re working with groups of names or titles. Ranges are specified in set brackets. A match is made
when any one of the characters within the set brackets, not necessarily all the characters, is found.
Descriptions of how to match character ranges with regular expressions are shown in Table 8-5.
TABLE 8-5
Regular Expression Character Ranges
Character Matches Example
[abc] Any one of the characters a, b, or c [lmrt] matches the individual l and m’s in
lemmings, and the r and t in roadtrip.
[^abc] Any character except a, b, or c
[^etc] matches each character in GIFs, but not etc
in the phrase GIFs etc.
[a-z] Any character in the range from a to z
[l-p] matches l and o in lowery, and m, n, o, and
p in pointman.
x|y Either x or y
boy|girl matches both boy and girl.
Using grouping with regular expressions
All the regular expressions described previously relate to finding a certain string of text within your
documents. But after you’ve located a particular string using regular expressions, how can you use
that particular string in the Replace With field? For example, the following list of names:
John Jacob Jingleheimer Schmidt
Jame ...