Construct a GREP expression

Last updated on Jun 2, 2026

Learn how to construct and use GREP expressions to search and replace complex text structures in Adobe InDesign.

Use GREP (Global Regular Expression Print) expressions to find and replace alphanumeric strings and patterns across multiple open documents. They help find and modify structured content such as phone numbers, email addresses, and formatted text. GREP works across single or multiple documents and supports bulk updates.

Find and change text using GREP expressions

Select Edit > Find/Change, select the GREP tab.

In the Find what field, select an option:

Type or paste the replacement text in Change to. You can also replace any found text with a specific text case by selecting the Special characters for replace icon and then selecting Case Modifiers.

Select any case modifier to change the text case of the found text.

Select a search scope from the Search drop-down menu.

Select Find Next to locate the first match.

Select Change, Change All, or Change/Find.

GREP requires a basic familiarity with pattern syntax, but built-in character menus on InDesign help you construct expressions without memorizing codes.

Find text within quotation marks and reformat

Select Edit > Find/Change, then select the GREP tab.

In the Find what field, type (")(\w+)(") to search for any text enclosed in quotation marks.

Select the Special characters for replace icon, then select Found > Found Text to populate Change to with $0. Use $1, $2, or $3 in the Change to field to replace individual groups defined by parentheses in your expression. $1 targets the first set of parentheses, $2 the second, and so on.

Select the Specify attributes to change icon in the Change Format section, then select your formatting.

Select Find Next to locate the first instance.

Select Change, Change All, or Change/Find to replace text and continue searching.

Sample GREP expressions

Find criteria

GREP Expression

Example

Class of characters

[]

Type the following to find a, b, or c:

[abc]

Negative Lookahead

(?!pattern)

Avoid a certain pattern in your search. For example, to avoid finding InDesign CS versions from a list of InDesign versions, type:

InDesign (?!CS.*?)

Positive Lookahead

(?=pattern)

Find a certain pattern. For example, to find only InDesign CS versions from a list of InDesign versions, type:

InDesign (?=CS.*?)

Case-insensitive On

(?i)

Find text irrespective of the typing case. For example, if you want to find Apple in any case (apple, APPLE, and so on), type:

(?i)apple

Case-insensitive Off

(?-i)

Find case-sensitive text. For example, if you want to find only Apple (not apple, APPLE, and so on), type the following:

(?-i)apple

Find a character or word a certain number of times

{ }

Type any of the following to find the repeat number of a character or word:

b{3}: Matches exactly 3 times

b(3,}: Matches at least 3 or more times

b{3,}?: Matches only 3 times

b{2,3}: Matches at least 2 times and not more than 3

The following examples use common GREP replacement syntax conventions:

  • \$1 $2: Adding a single backslash (\) acts as an escape character.
  • \\u $1 \u$2: Adding two backslashes (\\) outputs a single backslash and allows escape characters to appear in the output.
  • \u$1 \\n \u$2: Passing \n to the output inserts a new line.

Find criteria

Find expression

Find result

Change expression

Change result

Find two words with a space in between and interchange their position, or add anything in between or at the end.

(\w+)\s(\w+)

Adobe InDesign

$1 $2

$2 $1

$1, $2(™)

$1 $2: Adobe InDesign
$2 $1: InDesign Adobe

$1, $2(™): Adobe, Indesign(™)

Change the case of the first letter in a group

(\w+)\s(\w+)

Adobe InDesign

\l

\u

\u$1 $2
\u$1 \u$2
\l\l\u$1 $2
\u$2, \u$1

\u$1 $2: Adobe indesign
\u$1 \u$2: Adobe Indesign
\l\l\u$1 $2: aDOBE INDESIGN
\u$2, \u$1: Indesign, Adobe

Change the case of all letters in a group

(\w+)\s(\w+)

Adobe InDesign

\L

\U

\U$1 $2

\U$1 \U$2

\U$1 \u$2

\U$1 $2: ADOBE indesign

\U$1 \U$2: ADOBE INDESIGN

\U$1 \u$2: ADOBE Indesign