Members Only

Using Square Brackets in Your InDesign GREP Search

When you’re looking for one of many possible characters in GREP, brackets let you make a list.

This article appears in Issue 65 of InDesign Magazine.

Looking for a vowel? GREP lets you find a, e, i, o, or u, by placing brackets around them like this: [aeiou]. In other words, brackets create a list of possible matches, as though saying “any one of these.” One of the most common uses for a bracket list is searching for variations of the same letter. For example, [aA] will find a lowercase or uppercase letter a.

You can find even more variations of a letter by placing it inside brackets and equal symbols. For example, [=a=] will find a, A, â, ä, á, à, Å, and more—those are all considered variations of the letter a.

The bracket expression can also be turned around to find characters not in the list. For example, [^aeiou] means any character except vowels—the caret symbol at the beginning means “not.” I find this particularly helpful when searching for character that is not punctuation.

You can even search for a range of characters. For instance, [A-Fa-f0-9] will find any hexadecimal number (any number between zero and 9, or any upper- or lowercase letter between a and f. I show how to use this technique to find all Japanese characters in text in this post.

As you know, some characters have special meanings in GREP, such as the dot, asterisk, and dollar symbols. However, all but the backslash lose their meaning in a square bracket expression. For example, [ .,*[] means find a space, period, comma, asterisk, open left bracket, or tab.

Of course, if you’re actually searching for a bracket in your text, you’ll have to “escape” it with a backslash. For example, \[a\] finds this text: [a].

InDesign find/change dialog box shows GREP search term:[-uld._]+@[-uld_]+.[ul]{3}

Bookmark
Please login to bookmark Close

Not a member yet?

Get unlimited access to articles and member-only resources with a CreativePro membership.

Become a Member

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *