Tech Tip – Indesign GREP Styles for Proposals and SOQs

What can GREP do?

GREP can be used in both InDesign’s Find/Replace and Paragraph Style functionality. For the purpose of this article, we will focus on grep styles.

Consider the following GREP functionalities for proposals and SOQs:

  1. Prevent hyphenation or breaking of company names and other important words or phrases.
  2. Automatically prevent runts (i.e., a single word left on its own line).
  3. Automatically apply a character style to phone numbers
  4. Automatically apply a character style to email addresses
  5. Automatically apply a character style to urls
  6. Automatically superscript copyright symbols
  7. Automatically superscript ordinals
  8. Automatically apply a character style to missing information markers

Notice the repetitive reference to “Automatically”? That is because, InDesign does this on the fly.

Before we dive in, let’s talk about prerequisites.

  1. You should understand how to use paragraph styles, character styles, and object styles.
  2. They should be in your everyday workflow and the backbone of all of your documents.

Using InDesign without using styles is similar to buying a fancy automobile and never turning on the air conditioner, never using cruise control, never listening to the sound system, never opening the sun roof, and never using off-road capabilities in an urban environment.

If you are a regular InDesign user and do not meet the above prerequisites, I strongly urge you to consider the use of styles. is my personal favorite for informative video tutorials. Michael Murphy’s InDesign Styles in Depth and other videos by InDesign masters, such as David Blatner, Deke McClelland, and Anne-Marie Concepcion, are available on Lynda. A simple Google search will yield a wealth of guides


Indesign styles are all about efficiency through all phases of your document workflow. For example, I have character styles to apply custom formatting to email addresses, urls, and telephone numbers. I also use a character style labeled “no break” to ensure Moss Construction and any other entity of importance do not break to the next line.

Simple styles like this ensure I can make cascading changes to an entire document through one simple style; however, I still have to manually apply them to my content. This is where GREP comes in.

GREP, which stands for “globally search a regular expression and print”, is command line utility for searching text that has been around since the 1970s.

At first glance, a GREP expressions looks like what happens when you fell asleep at the keyboard during a late night project. I urge you to read on and give GREP a chance. Even if you do not learn how to write GREP expressions blindfolded, there are many useful examples described in this article which can be cut and pasted into your workflow.

I will describe how to implement each of these eight items. I suggest that you cut and paste these examples into your own layout to experience first-hand how powerful and convenient they are. You can pick and choose what seems useful to you and stop there or review the illustrations to better understand how expressions are structured. It is your choice!

How to add a GREP style

Open a paragraph style, select “Grep Style” from the column of options, and select “New GREP Style”.

If you check the “Preview” check-box in the lower left hand corner, it will make these changes visible prior to closing the paragraph style dialog box.

grep 1

Grep Styles have two fields have two options. The first is indicates the character style that you want to apply based upon the grep expression. You can select from existing character styles or create a new one from within this dialog.

grep 2

The second field is where you place your grep expression. Adobe provides a handy drop-down guide for inserting arguments,

grep 3

How should I structure my paragraph and character styles

I place many of the aforementioned grep expressions within a default paragraph style and add the associated character style to my starter documents. I try to avoid getting too carried away with basing one style off of another; however, I do set up three basic  styles (Defaults, Defaults-Paragraphs, and Defaults-Headings). The latter two are based on the first and all paragraph and heading styles are based on these defaults.  All of my grep styles are included in the Default-Paragraphs. This ensures that that all of my paragraph styles inherit my grep styles.

In some cases, I add the grep expression and leave the associated character style void of settings. This gives me the ability to easily implement certain formatting at the last minute without fumbling with and testing grep expressions from other documents.

Useful expressions

1. Prevent hyphenation or breaking of company names and other important words or phrases.

This is one of the simplest expressions. You can set one or more words by separating them with a pipe. For example:

Company or Phrase One|Company or Phrase Two|Company or Phrase Three

This is case sensitive, which would be okay for a company name but maybe not a phrase. If you have a phrase that may be capitalized or not, you can use the Or expression (?i)

Lets break that down:

grep guide v1 1

What grep finds and styles from the following sample text: Company or Phrase One reported a quarterly net loss on Thursday due to large restructuring charges and falling sales of specialty plastics and chlorine. For the fourth quarter the Company or Phrase Two posted a net loss of $716 million, or 61 cents per share, compared with a net loss of 20 million, or 2 cents per share, in the year-earlier quarter. Company or Phrase Three is awesome.

2. Automatically Prevent Runts

In my opinion, this expression addresses a missing feature in InDesign. It looks for runts (i.e., single words left on their own line) and applies a character style with “no break” to fix the problem automatically.


Lets break that down:

grep guide v1 2

I found this expression from a comment by Atelier Jloupf on Otto Coster’s article over at Vector Tuts:

3. Automatically apply a character style to phone numbers

If you want to apply a particular format to telephone numbers, the following expression will look for a wide variety of telephone number formats including extensions.

\(?\d\d\d\)?[-. ]?\d\d\d[-. ]?\d\d\d\d( ?(?i)x(\d+))?

Lets break that down:

grep guide v1 3

What grep finds and styles from the following sample text: My telephone number is 654.235.7868. If you can’t reach me at that number, try my office at (524) 752-5754 x502. I could also be at the lake. My lake house number is 765-235-8675.

I added functionality to handle extensions that use an “x”. You could easily add the ability to search for “Ext” or similar.

I also considered adding the ability to handle international numbers. However, international numbers can be tricky and I wanted to minimize the likelihood that grep would style something arbitrary such as a serial number.

4. Automatically apply a character style to email addresses

If my documents are to be published digitally, I always ensure that all email addresses are exported as hyperlinks. I like to differentiate these interactive elements and generally use a character style. The following grep expression can handle this.


Lets break that down:

grep guide v1 4

What grep finds and styles from the following sample text: My email address is Please CC my wife. Her address is I will forward your information to tim. Tim’s email address is

This one came from David Blatner’s post on I considered removing the {2,4} and replacing it with a + to shorten the expression. It won’t be long before a wide range of new domain names become available. These will likely be longer than four characters.

5. Automatically apply a character style to urls

Similar to email addresses, the following expression can apply a character style to a url.


Lets break that down:

grep guide v1 5

What grep finds and styles from the following sample text: Check out my website at If you like that site, check out I also have some files accessible via my ftp server at

6. Automatically superscript copyright symbols

I like to keep my copyright symbols superscript. The fonts that I typically use have trademark and registered trademark symbols drawn in superscript; however the copyright symbol is a standard size character. I understand why; however, I never use the full size symbol. The following expression takes care of this:


Lets break that down. Its pretty easy.

grep guide v1 6

7. Automatically superscript ordinals

I really like to have my ordinals in superscript. The following expression will look for Xst, Xnd, Xrd, Xth and apply an associated character style with the superscript option set.


Lets break that down:

grep guide v1 7

What grep finds and styles from the following sample text: We should be your 1st, 2nd, 3rd, and 4th choice.

8. Automatically apply a character style to missing information markers

I often use “INSERT” with a magenta swatch titled “NEEDS ATTENTION” in my documents. I can then use the find tool for the word “INSERT”, the preflight workflow that looks for the swatch to find missing information, or even manually scrolling through a document to find these items.

One thing that has bothered me is that when I paste in the missing information, I then have to clear overrides on the paragraph style or click [None] in the character style pallet.

I decided to use grep to automatically apply a character style to an entire paragraph when it sees the word “INSERT” in all caps. This way, when I replace INSERT with the desired content, the magenta fill is automatically removed. I do this using the following expression:


Lets break that down:

grep guide v1 8

What grep finds and styles the following in a sample strings of text: INSERT is the individual you should speak to.

To get more information, please call INSERT.

GREP Resources & Closing Comments

Michael Murphy’s colorful illustrations of grep expressions was my inspiration for the breakdowns. I have found a significant number of useful resources and have provided them below. When reviewing these pages, take note of the comments section. Check these sites out:

  1. General – Cari Jansen’s blog
  2. Positive lookbehinds – Cari Jansen
  3. Negative lookaheads – Cari Jansen
  4. Proportional Oldstyle – Barb Binder
  5. General Grep – Theunis de Jong
  6. 5 Cool Things You Can Do with GREP Styles – David Blatner
  7. 5 Cool Things You Can Do with GREP Styles – David Blatner
  8. Grip on Grep – Cari Jansen
  9. Never Break up Dates, Names, or Times – Colin Flashman
  10. Fun with Grep – Erica Garmet
  11. Grep in InDesign – Michael Murphy
  12. Killing Runts in Indesign with Grep – AB
  13. Custom Kerning in Indesign – Nina
  14. Saved my favorite for last

I have tested these expressions to try to break their functionality; however, I am also certain that responses to this post will yield simpler solutions or potential problems. Comments, questions, and suggestions are always welcome.