A Little GREP Gripe

The ability to use GREP in a Find/Change is pretty sweet, but there's at least one limitation that could leave a bad taste in your mouth.

Here’s a little GREP quirk I stumbled on a while back.

When you do a GREP Find/Change and include Find Format settings, InDesign only finds instances where the formatting is applied to content matched by the entire GREP expression. And that may leave you feeling rather unsatisfied if you use any of the Lookahead or Lookbehind features in your GREP search.

Consider this example. You have a document with lists of text and numbers set in black and red.

You need to find all instances of red numbers that follow a comma. That seems easy enough. In the Find/Change dialog box, you can create a GREP search with the Positive Lookbehind feature to search for items based on what precedes them.

You tell InDesign to find numbers that are preceded by a comma and a space

and filled with red.

Unfortunately, your search will only turn up instances where the commas are also red. Numbers preceded by commas filled with any other color will not be found, just like those jelly donuts in the coffee shop.

I find this frustrating because the way I see it, the GREP expression matches digits that come after the comma and the space. You can see this when you execute the Find/Change.

See how only the numbers are highlighted? InDesign is just taunting us now. It knows we’re only looking for red numbers, but it won’t give them to us.

You can also use the same expression in a GREP style and the formatting will only be applied to the numbers.

So why doesn’t it work the same in a Find/Change? I have to shrug my shoulders like that kid in the coffee shop and say I don’t know. Maybe one of the GREP gurus out there can explain this behavior. It’s a disappointing limitation for GREP Find/Change, and if you ever run into it you’ll have to find a workaround.

Or just order the bagels instead. ;)

Bookmark
Please login to bookmark Close

This article was last modified on December 20, 2021

Comments (40)

Leave a Reply

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

Loading comments...