Troubleshooting

GREP is a symbolic system, and it is easy to lose track of certain formal aspects. We’re not helped by GREP’s interface: entering complex expressions can be a challenge in such a confined space, and the miniscule type in the Find What and Change to fields doesn’t help either. Nor are we warned about errors in an expression: InDesign accepts anything. Recalcitrant expressions can be frustrating, but there are a number of things to look out for when troubleshooting expressions.

Patch to InDesign’s Latest Version

Always try to use the latest version of InDesign. Use Window > Updates . . . to check if there’s an update to the InDesign version you use (pre-CC) or install the latest InDesign version from the CC application.

Escape Characters

It is easy to forget to escape certain characters, so if an expression doesn’t work this is the first thing to check. Characters to be escaped are the ones that have a special meaning for GREP: . $ ? ^ * () [ ] { } + |. For example, if you’re looking for a digit in parentheses, be sure to escape the parentheses: \(\d\).

Some of these characters are problematic. For instance, various versions of InDesign have difficulty matching the dollar symbol ($). This is awkward because you can’t find dollar prices: \$[\d.,]+ doesn’t work as expected. The workaround in many cases is to use the character’s Unicode value: \x{0024}[\d.,]+ does match dollar prices. Another possibility is to use the dollar symbol as a character class: [$][\d.,]+.

Get GREP in InDesign now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.