Monday, October 12, 2009

Use GREP find to truncate lines of text

A student from one of my on-site InDesign training classes asked how to remove the end of each line of text in an InDesign-created directory listing, as shown in the example below. Each line of the directory consists of some text, a tab character, more text, and then a paragraph return.

In her email, she said "there are thousands, nay, millions of these pesky things...can Indesign find and replace wildcard strings?"

InDesign CS3/CS4's GREP Find/Change feature is made for just this sort of thing. Choose Edit > Find/Change, and fill in the dialog box as shown below.

In this case, \t represents a tab character, and the plus sign after it means to look for "one or more" tab characters. The period stands for "any character", and the asterisk after the period means to look for "zero or more" of "any character". So the entire Find phrase means "look for one or more tab characters that may or may not be followed by additional characters." Since the "Change to" field is empty, the found text will be replaced by nothing.


Inkling said...

If you like this sort of thing and use a Mac, go to:

and ask Apple to add GREP to the text features available in the next version of OS X. Then almost every text application will have them.

melinjo said...

do u have a reference for other GREP command?

Keith Gilbert said...

For a list of other GREP resources, see