Friday, June 08, 2007

GREP searches in InDesign CS3

The Find/Change dialog box in InDesign CS3 has several new features, including the ability to do "GREP" searches. GREP searches use “regular expressions” to allow you to search for patterns in text. For example, you could use a GREP search to find all the email addresses in a document and make them blue, or find all telephone numbers, regardless of format, and reformat them with periods like 888.555.1212.

Today, while preparing a quick reference guide for one of my classes, I needed to search through a file that contained about 1200 paragraphs, and delete the 900 or so paragraphs that contained the phrase "none defined". Entering ^.*(none defined).*$ into the Find what field of the GREP section of the Find/Change dialog tells InDesign to find each occurrence of the phrase "none defined" and then select the entire paragraph containing the phrase. In the Change to field I entered nothing, clicked on the Change All button, and was done. A huge time saver.

The GREP syntax is pretty twisted. If you like programming, scripting or Sudoku you will be able to learn GREP as needed. Here are a few resources to get you started:

First, visit the GREP section of the Adobe help resource center. Then download a handy GREP quick reference guide in PDF format. Issue #17 of InDesign Magazine has a great non-technical article by Sandee Cohen on how to begin learning GREP. Here is good GREP reference site.

If you don't care to tackle learning GREP , at the very least, keep a text file on your hard drive that contains examples, like the one above, that you can copy and paste as you need them. You don't have to understand GREP to use examples that closely match what you need.

1 comment:

Anonymous said...

Thank you!