Highlighting the benefit of GREP… literally

I’m a fan of the GREP feature of the Find/Change dialog box in Adobe InDesign as it allows me to search for patterns of characters within text based on regular expressions.

As handy as this feature is, I always require assistance writing my GREP searches, just in case my patterns are either too greedy; or not greedy enough. For example, I have a GREP search to find duplicate entries and remove them, but in InDesign the only way to know if I have this correct is to press the Find Next button in the search.

A better way to identify if I have my GREP search correct is to see it in real-time. Luckily, text editors such as BB Edit have this feature.

InDesign’s latest rival, Affinity Publisher, not only has its own flavour of GREP, but also shows all results in the Find and Replace dialog box, though I have to click on each result in this dialog to see where they are.

But it would be great if InDesign highlight the GREPs ahead of time like these two applications. The good news is that it can, but it requires the GREP editor script from Peter Kahrel that has been featured on Colecandoo before.

Thanks to Peter’s GREP editor, I’m now able to see that in this example there are three search results and they are all highlighted.

This tool comes in very handy as it assists me to write more complicated GREP searches, such as this one that is looking for time formatting. This lets me know in real-time if my selection is selecting too much information, or not enough – and in this example, it isn’t enough as the times without the minutes aren’t getting selected.

As for longer, more complicated chains of GREP code, there are resources out there that have pre-baked search chains that other users have already submitted to sites such as RegExLib.com or the Treasures of GREP Facebook group.

Stop Press!

After this article was initially published, I was alerted to another InDesign javascript by Kerntiff Publishing System that has a similar behaviour to Affinity Publisher’s search. The script is called GREP Xtra.

There is also an additional script released in 2013 by Roland Dreger that performs as a combination between Peter Kahrel’s script and the InDesign user interface. That script is called Highlight GREP.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.