Large projects in InDesign: book, brochure, catalog

Mastering GREP in InDesign: Wildcards, Repetitions, and Positions

All videos of the tutorial Large projects in InDesign: book, brochure, catalog
Katharina Frerichs
By Katharina Frerichs and Anne Fläschner Last updated on Shown in: Adobe Illustrator CC

Imagine a 300-page catalog in which hundreds of percentage figures have to be formatted consistently. Doing this by hand would be tedious clicking work. With the GREP search in Adobe InDesign, you can get it done in a few minutes. GREP stands for "Global Regular Expression Print" and is based on regular expressions, a language of characters and symbols that you use to describe patterns instead of fixed words. At first glance it looks cryptic, but the logic is manageable. In this guide, I will walk you step by step through the most important building blocks and show you, using a practical example, how to build a search, save it, and share it with colleagues.

Large projects in Adobe InDesign - 3.06 - Excursus GREP

The video is only loaded from YouTube when you play it – data (including your IP address) is then transmitted to YouTube/Google. More in the privacy policy

Key Takeaways

  • GREP searches for patterns instead of fixed character strings and thus saves an enormous amount of time on large projects.
  • The basic building blocks are characters, wildcards, repetitions, and positions, supplemented by alternatives and surroundings.
  • With parentheses, you mark parts of a pattern that you reuse when replacing via $1.
  • Saved queries can be shared as a file, so that entire teams can work with the same search patterns.

Step-by-Step Guide

Step 1: Open the GREP tab

Open the "Find/Change" dialog with Ctrl+F (Command+F on a Mac). Then switch to the "GREP" tab at the top. The normal text search remains available to you; you simply get an additional mode in which you formulate patterns.

Mastering GREP in InDesign: Wildcards, Repetitions, and Positions

Step 2: Define the search scope and inclusion options

In the "Search" area, you determine whether InDesign should search in the current document, in all documents, or only to the end of the story. Below that, you specify whether master pages, locked objects, and locked layers are included. Set these options deliberately, because otherwise the search will overlook elements or change content you never meant to touch.

Mastering GREP in InDesign: Wildcards, Repetitions, and Positions

Step 3: Include formatting in the search

Via the format options, you can search specifically for underlines, bold text, paragraph styles, or character styles. This is especially helpful when you only want to catch text passages with a particular style.

Mastering GREP in InDesign: Wildcards, Repetitions, and Positions

Step 4: Explore the symbol list

The biggest difference from the normal search lies in the symbol list. There you will find significantly more options than in the simple text search. GREP works with five categories: single characters, wildcards, repetitions, positions, as well as alternatives and surroundings. The list is therefore not an end in itself, but your toolbox for all the following steps.

Step 5: Use characters and wildcards

You search for a single character such as a capital A just as you would in the normal search. Wildcards are where it gets interesting. The period stands for any character, \d for any digit, and \s for a whitespace character. If you enter a. for example, InDesign finds an a followed by any character. You don't have to memorize these codes, because you can select them from the symbol list at any time and combine them into a pattern.

Mastering GREP in InDesign: Wildcards, Repetitions, and Positions

Step 6: Control repetitions

With repetition characters, you define how often an element may occur. The plus sign + stands for once or more, the asterisk * for zero times or more, and the question mark ? for zero times or once. If you repeat any letter with +, the search finds all words from the first letter to the end of the word. Whitespace is not included.

Mastering GREP in InDesign: Wildcards, Repetitions, and Positions

Step 7: Define positions in the text

Position characters determine where a match must be located. The caret ^ marks the beginning of a paragraph, the dollar sign $ the end. With ^a. you therefore find only words that start with an a at the beginning of a paragraph. This lets you narrow down your search precisely without having to check every match.

Mastering GREP in InDesign: Wildcards, Repetitions, and Positions

Step 8: Use alternatives and surroundings

The vertical bar | separates alternatives. The pattern a|b therefore finds both a and b. Even more elegant are context conditions: With (?=...) you check what follows a character, and with (?<=...) what precedes it. The checked characters are not highlighted in the process. This allows you to expand the search precisely, even at an advanced level.

Mastering GREP in InDesign: Wildcards, Repetitions, and Positions

Step 9: Starting the Practical Example – Number and Percent Sign

Now we apply the building blocks. The goal is to format entries like "10 %" or "80%" consistently, that is, with a thin space (one-eighth em space) between the number and the percent sign. First, you need a search pattern for any digit, followed by a whitespace and the percent sign. Enter \d\s% for this. This pattern finds all places where a digit with whitespace is followed by a percent sign.

Step 10: Making the Whitespace Optional

For entries like "80%", the space is missing entirely, and your pattern would overlook them. Therefore, add the question mark after \s, so \d\s?%. The search now accepts zero or one space. Alternatively, you could use \s*, which also captures multiple spaces.

Mastering GREP in InDesign: Wildcards, Repetitions, and Positions

Step 11: Grouping Matches and Using Them When Replacing

Parentheses form groups that you can call up again when replacing. Write the search pattern as (\d)\s?%. The digit is now in group 1. In the "Replace with" field, you write $1, then insert the thin space and the percent sign. You can find the thin space under Type > Insert Special Character > White Space. This way the number is preserved, and only the spacing is corrected.

Mastering GREP in InDesign: Wildcards, Repetitions, and Positions

Step 12: Covering Further Units with an Alternative

You can extend the pattern so that it recognizes not only percent signs but also periods. The notation (\d)\s?(%|.) finds both variants. In the replacement, you then use $1, the thin space, and $2. Test the search first via "Find" before replacing larger areas, so that you can check the matches.

Mastering GREP in InDesign: Wildcards, Repetitions, and Positions

Step 13: Reading the Abbreviations Correctly

Many abbreviations follow a logic that is quickly memorized. Standard characters from the world of regular expressions begin with a backslash, such as \d for digits. InDesign-specific characters, such as the tab for right-aligned alignment or an indent, are on the other hand marked with a caret, for example ^t for the tab. This distinction helps you remember them when you work with GREP for a longer time.

Mastering GREP in InDesign: Wildcards, Repetitions, and Positions

Step 14: Saving Queries and Sharing Them with Colleagues

You shouldn't rebuild a finished search every time. Click the save button at the top of the dialog, assign a meaningful name, and confirm. Your query is then available in the selection at any time, even if you have performed other searches in between. The saved queries are stored as a small file in the InDesign program folder. If you copy this file into the same folder on a colleague's computer, they can use your search patterns as well. Make sure the InDesign version is identical.

Mastering GREP in InDesign: Wildcards, Repetitions, and Positions

Summary – GREP Search in InDesign: Using Wildcards, Repetitions, and Positions Effectively

The GREP search in InDesign is far more than an extended text search. With it, you describe patterns instead of individual words and combine characters, wildcards, repetitions, positions, and alternatives. Once you have understood how these building blocks work together, even complex tasks such as consistently formatting percentage figures can be solved reliably. With parentheses and the variable $1, you replace parts of a match in a targeted way, and saved queries make your work repeatable in a team. Start with simple patterns and expand them step by step, and you will quickly become more confident.

FAQ

What does GREP mean in InDesign?GREP stands for "Global Regular Expression Print" and refers to searching with regular expressions, with which you search for patterns instead of fixed terms.

Do I have to memorize the GREP symbols?No, the symbol list in the GREP tab offers all the building blocks to choose from. Over time, though, the most common abbreviations will stick on their own.

What is the difference between \d and the period?\d stands only for a digit, whereas the period stands for any character.

How can I save a search for later or for colleagues?Save the query using the corresponding button in the GREP tab. You can pass the saved file from the InDesign program folder on to colleagues who use the same program version.

923,235,1046,637,1048,434
Katharina Frerichs
Trainer About Katharina Frerichs Katharina Frerichs is a media designer, publishing producer and mediator. As the owner of Satzkiste, a publishing service provider in Stuttgart, she is involved in the planning and implementation of extensive projects in InDesign on a daily basis. All courses by Katharina Frerichs
Anne Fläschner
Trainer About Anne Fläschner Anne Fläschner is a trained media designer with a degree in cultural and media education. She has been working at Satzkiste since 2009 and works closely with various publishers. All courses by Anne Fläschner