beautypg.com

Adobe InDesign CS3 User Manual

Page 145

background image

INDESIGN CS3

User Guide

138

Phone numbers in the United States can appear in a variety of formats, such as 206-555-3982, (206) 555-3982,
206.555.3982, and 206 555 3982. This string looks for any of these variations. The first three digits (\d\d\d) of the
phone number may or may not be enclosed in parentheses, so a question mark appears after the parentheses: \(? and
\)?. Note that the backslash \ indicates that the actual parenthesis is being searched for and that it’s not part of a subex-
pression. The brackets [ ] locate any character within them, so in this case, [-. ] finds either a hyphen, a period, or a
space. The question mark after the brackets indicate that the items within it are optional in the search. Finally, the
digits are enclosed in parentheses, which signify groupings that can be referred to in the Change To field.

You can edit the grouping references in the Change To field to suit your needs. For example, could use these expres-
sions:

206.555.3982 = $1.$2.$3

206-555-3982 = $1-$2-$3

(206) 555-3982 = ($1) $2-$3

206 555 3982 = $1 $2 $3

Additional GREP examples

Experiment with these examples to learn more about GREP searches.

Expression

Search string

Sample text

Matches (in bold)

Class of charac-
ters

[ ]

[abc] or [abc]

Finds the letter a, b, or c.

Maria cuenta bien.

Maria cuentabien.

Beginning of
paragraph

^

^~_.+

This searches the beginning of the para-
graph (^) for an em dash (~_) followed by
any character ( . ) one or more times (+).

“We saw—or at least we think we
saw—a purple cow.”

—Konrad Yoes

“We saw—or at least we think we
saw—a purple cow.”

—Konrad Yoes

Negative looka-
head

(?!pattern)

InDesign (?!CS.*?)

The negative lookahead matches the
search string only if it is not followed by the
specified pattern.

InDesign, InDesign 2.0, InDesign CS,
and InDesign CS2

InDesign, InDesign 2.0, InDesign
CS, and InDesign CS2

Positive looka-
head

(?=pattern)

InDesign (?=CS.*?)

The positive lookahead matches the search
string only if it is followed by the specified
pattern.

Use similar patterns for negative lookbe-
hinds (?pattern) and positive lookbehinds
(?<=pattern).

InDesign, InDesign 2.0, InDesign CS,
and InDesign CS2

InDesign, InDesign 2.0, InDesign
CS, and InDesign CS2

Groupings

( )

(quick) (brown) (fox)

The quick brown fox jumps up and
down.

The quick brown fox jumps up
and down.

All found text = quick brown fox;
Found Text 1= quick; Found Text 2
= brown; Found Text 3= fox