Text Cleanup in InCopy using GREP

This past week I was talking with a group of editors who were lamenting about the amount of time that they spend each day cleaning up text from Word content that they place into InCopy. Specifically they were talking about numbered items in the Word document. This piqued my curiosity because I know full well that numbered and bulleted lists in Microsoft Word are handled quite well by InCopy and get converted to native numbered and bulleted lists when imported. Upon further explanation, it turns out in their case, that the numbering applied in Word was done manually instead of using the numbered list feature built into Word.

This actually explained quite a bit. What was happening was that when they imported the manually numbered items into InCopy and applied the numbering paragraph style to the text, they ended up with double numbers. One number generated automatically and one number that was manually typed. Let it be said, that it is one of my missions in life, to get users to use Word (and other applications) correctly, but I’m not going to achieve that anytime soon.
Double Numbered List

GREP to the Rescue!

Their current solution to the problem was one that basically involved manually removing the number, the period, and the extra spaces for each numbered item because they tried with little success in the past to fix the problem using Find/Change. Although Find/Change was close to the correct solution, they just needed to go a little bit further in the dialog box to find GREP. I wrote an introductory post on GREP in InCopy here, so if you’re totally new to GREP, you might want to familiarize yourself with it.

GREP takes Find/Change to a whole new level by allowing a user to build intelligence into a search. Start by making sure your cursor is within the story that you want to edit and that the story is checked out (if applicable). Open the Find/Change dialog box by pressing Cmd+F (Mac) or Ctrl+F (Windows) and click on the GREP button at the top of the dialog box. Directly to the right of the Find What field, click on the @ symbol to specify special characters in your text to search. In the drop-down menu, choose Wildcards > Any Digit which will insert \d into the Find What field which is the regular expression for a digit. This search alone will find any numeric digit in your file. This is not specific enough for our example so we’ll need to define more properties to search.

Directly to the right of the \d in the Find What field, type \. (backslash period). In the GREP language, whenever you want to find a literal character, you need to precede it with a backslash which tells GREP that the text you’re typing is not part of its language but instead is defining the literal text. Now we’re finding a digit followed by a period. At this point I’ll press the Find Next button a few times to test my search so far to see if I’m on the right track. Make sure your cursor is to the right of the period in the Find What field and click on the @ symbol and choose Wildcard > Any White Space. Click on the @ symbol again and choose Repeat > One or More Times which tells InCopy that there could be one or more space in a row. This bullet-proofs the search a bit because it accounts for inconsistencies in the number of spaces that might appear after the period.

Letting GREP do the Heavy Lifting

The Find What field should now look like this \d\.\s+ which is basically saying find a digit followed by a period, followed by one or more spaces. Make sure that the Change to field is blank and click the Change All button and watch InDesign remove all of those extra characters.

GREP Find Change dialog box

GREP Find_change

Save that Search!

Don’t worry, you don’t have to be a GREP guru to make use of this fantastic feature. You don’t even need to remember what to type in! Once you build a GREP search like we did here, simply click the Save Query button at the top of the Find/Change dialog box, give it a name, and click save. Now you can choose it from the Query drop-down menu any time you need to use it!

The Save Query button

The beauty of GREP is that once you figure it out, it can save you literally hours of manual work. Once you figure out the correct GREP for your situation, save it and enjoy the fruits of your labor. I’d like to know about other text cleanup issues that you wrestle with on a daily basis. Post them in the comments section below, and I or someone else in the InCopySecrets community will respond to your question. If we get some interesting examples, I’ll write it up as a post here at InCopySecrets.com. Until next time!

Leave a Reply

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