Join Michael Murphy for an in-depth discussion in this video Working with GREP and InDesign, part of Learning GREP with InDesign.
GREP is integrated into two completely separate features in InDesign CS4. Let's take a quick look at the two places where you will work with GREP within the application. Since InDesign CS3, GREP has been part of Find/Change, which is available from the Edit menu>Find/Change or by using a keyboard shortcut, Command+F on a Mac or Ctrl+F on Windows. The Find/Change dialog has a Text tab and a GREP tab, as well as a Glyph and Object tab. And on first glance the Text tab and the GREP tab are not terribly different from one another, until you look at a few specific details.
In the Text tab, there is a Case Sensitive button and a Whole Word button. In the GREP tab, those options are not available because all GREP searches are case-sensitive by nature and there are different ways, in GREP, to describe a whole word. Also, in the Text Find/Change tab, if you go to the Special Character's menu at the end of the Find what field, there are a limited number of options available to you. In the GREP tab, if you go to that same button, there are far more options available, and most of the GREP options begin down here after the other submenu and include Wildcards, Locations, Repeat and any number of others.
At the end of the Change to field, there are fewer options, but the key in GREP is this Found sub-menu, which we'll discuss in a later movie. If you are still only working in CS3, this is where you will work with GREP, and I should point out that in CS3 and CS4 there is virtually no difference between the GREP Find/Change features in either version of the application. So anything we discuss in this title about GREP Find/Change is going to apply even to the older version.
The other place where you'll find GREP in InDesign is only to be found in CS4, and that is GREP Styles. You can work with GREP Styles in any of the places where you typically work with text on the paragraph level. So, if you have your Text tools selected, you can access GREP Styles from the Control panel menu, at the far end of the Control panel, by choosing GREP Styles, from the Paragraph panel, going to its flyout menu and choosing GREP Styles. But the place where you really want to be working with GREP Styles is from within a Paragraph style, because it's the only place you can really preserve the work that you do and apply it to multiple paragraphs.
So if I were editing a style or creating a new paragraph style, which I'll do here very quickly, and I wanted to add a GREP Style to it, I would select GREP Style from the options on the left, and in this dialog box, in a nutshell, here, is how a GREP Style works. You create a new GREP Style. You choose, from the Apply Style menu, an existing Character Style or create a new one, and then in the to text field, you specify the GREP pattern that you want that Character Style applied to.
Now, this is the tricky part. That's entirely up to you. You have the Special Characters menu that we saw on the Find/Change dialog at the end of this field as well, so you can start to build your GREP expressions with what's available here. But in order to start actually working with GREP in InDesign, you need to know a little bit more about GREP in general, specifically, what all of those Special Characters are and how you put them together to make up regular expressions.
- Using metacharacters, the building blocks of GREP
- Describing text that may not exist with zero operators
- Applying multiple character styles to the same text with GREP styles
- Eliminating orphaned words at the ends of paragraphs
- Preserving and recalling subexpressions
- Customizing a GREP-based text cleanup script for long documents