Thanks for coming to, the world's #1 resource for all things InDesign!

5 Cool Things You Can Do with GREP Styles

I love GREP Styles in CS4. I’ve said it before: It’s probably my favorite new feature, and although it’s small, I think it makes the upgrade very worthwhile. But what are they, how do you make them, and what can you do with them?

A GREP Style is a way to apply a character style to some text inside a paragraph, based on a GREP pattern. GREP, as we’ve discussed, is a way to describe a text pattern using codes. For example, you can write “all the words that start with a and end with e” with the code \<a\S+?e\>

You can use GREP in the Find/Change dialog box, but only manually — that is, you have to actually do a search and replace each time you want to apply the formatting. GREP Styles don’t change text at all; they only apply formatting. But there are many things you can do with just that.

To apply a GREP Style to a pararaph, you probably want to edit your paragraph style definition. (You can apply a GREP Style to a single paragraph as local formatting by placing the cursor in the paragraph and choosing GREP Styles from the Control panel menu. But I find that in general it’s just more useful using GREP Styles inside a paragraph style.)

To make a new GREP style, click the New GREP Style button:

To apply a character style, click once on Apply Style and it turns into a character style. Then you can choose a style you’ve already made or choose New Character Style if you haven’t made one yet. (That’s another little feature I love in CS4.)

Type the GREP code in the To Text field. For example, the default GREP code \d+ means “one or more digits in a row.”

I encourage you to turn on the Preview checkbox to see how (or if) it works before clicking OK.

Five Cool Things You Can Do with GREP Styles

Okay, enough with the “how.” Now what about “what”. Bob Levine already posted about one way to use them here. Here are 5 more ways I like using GREP Styles. Please feel free to comment below with other ways you’re using this cool feature.

1. Oldstyle Numerals. Apply a character style that applies the OpenType Oldstyle Proportional figure style to all digits in a paragraph.

2. No Break words and phrases. I’m tired of setting individual words to “No Break” or changing dictionaries to instruct InDesign not to break words. If I don’t want to break “InDesign” on to two lines, I’ll just apply a no-break character style to the GREP code “InDesign” (that’s pretty simple grep, eh? Just type the word!)

3. Change Width of Em Dash. In some fonts, the em dash is just too wide for my tastes. No problem. Make a character style with a 75% (or whatever) horizontal scale. Then apply it to the em dash character. Don’t know how to type an em dash code? No problem. Just click the icon to the right of the To Text field. That shows you all kinds of cool codes for things.

4. Make OpenType Fractions. Jamie McKeee reviewed and explained the excellent Fraction script in the recent issue of InDesign Magazine. I added a little sidebar to that review before it went “to press” that explained that if you are using OpenType fonts that include the Fraction style, you can apply them with a GREP Style. Apply a “Fractions” formatting character style to the code \d+/\d+ (which means one or more digits, followed by a slash, followed by one or more digits.) It won’t work if you have commas or decimals in the fractions, but it’s a good start! (Of course, you could make a GREP code to handle those situations, too?)

5. Make Characters Disappear. My colleague and co-author Olav Kvern just wrote me, saying, “You really don’t need to find/change typical typewriter text entry errors (double spaces after periods, etc.) anymore–just make a grep style that does it and make it part of your base paragraph style(s).” Wow. Good point! But how to make a character disappear when you can only apply formatting? Make a character style that applies the fill color of None, a tiny point size, and a horizontal scale of 1%. Boom, it’s “gone.”

Dang, I can’t stop at five. Here’s one more you might find useful:

6. Replace text with icons. What if you want some text to convert into a special character? For example, everywhere you type some normal text, you want it to change into a special icon in a particular font. Here’s the before and after:

I found the ornament/symbol/glyph I wanted could be typed with the number “4” in Bodoni Ornaments. So then I made up a little easy-to-remember code that would never show up in normal text: “4z”. I then added two grep styles. The first one was 4(?=z) which means “look for the character 4 but only when it has the letter z immediately after it.” I applied my bodoni ornaments character style to that. The second grep style was (?<=4)z which is “find the letter z, but only when it has the number 4 before it.” To that, I applied my disappear character style.

What do you think? Can you think of other cool uses for this excellent feature?

David Blatner

David Blatner

David Blatner is the co-founder of the Creative Publishing Network, InDesign Magazine, and the author or co-author of 15 books, including Real World InDesign. His InDesign videos at are among the most watched InDesign training in the world. You can find more about David at
David Blatner

Latest posts by David Blatner (see all)

  • - November 30, -0001
Related Articles

127 Comments on “5 Cool Things You Can Do with GREP Styles

  1. Is there a way to use Grep to search and replace a placed eps icon with text?

    I have created hundreds of pages of tables which use icons as headers. Now I need to change the icons to text descriptors. For example a W eps icon now needs to become ‘Watts’.

    Any help please?

  2. Many thanks.

    I did come across and try that script.I managed to get the example working but I’ve not managed to amend the script for my use yet.I will try and get help from our web designer tomorrow as I don’t know how to amend script – I’m just a designer :)

    • Is there any way of using Find/Change to find a specific spot colour (in an eps graphic)? I know you can use the Object option to search for colours but they don’t seem to pick up colours in placed eps.

      Many Thanks

    • Hi Terrance,

      Take a look at “Favorite GREP Expressions You Can Use” available from the following weblink:

      It provides good examples on how to use the OR statement with GREP:

      Expressing Or

      (Milk|Dark) Chocolate Milk Chocolate or Dark Chocolate
      (m|M)ilk (c|C)hocolate Milk Chocolate, milk chocolate, milk Chocolate, Milk chocolate
      [mM]ilk chocolate milk chocolate or Milk chocolate
      [^m]ilk ailk, bilk, etc., but not milk
      (?i)milk Case insensitive: Milk, milk, mILk, etc.
      colou?r color or colour (the ? means the previous character or expression may or may not be there)

      Good luck!

Leave a Reply

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