GREP for Editors
If you’re like most people, you just got done reading the headline of this article and said “What in the world is GREP?” People who have been using InCopy for years, still aren’t sure what GREP is even though they probably see it every time they open the Find/Change dialog box.
GREP stands for General Regular Expression Print and although that probably doesn’t make things any clearer yet, just understand that GREP is like Find/Change on steroids. The premise behind GREP is that you build search terms using Regular Expressions that intelligently searches out text content with intelligence and precision accuracy. GREP can literally save hours of your time by cleaning up what you would normally do manually. If you think that GREP requires that you learn an obscure language in order to achieve find/change greatness, you’d be only partially correct. The point of this post is to introduce you to some GREP searches that you can use today without learning a single lick of code!
GREP is found in the Find/Change dialog box, so open it by choosing Edit > Find/Change or use the keyboard shortcut Cmd+F (Mac) or Ctrl+F (Windows) and click the GREP button at the top of the dialog box. This is where you can type in GREP expressions to search for content. As promised however, you won’t need to type anything in here! At the top of the Find/Change dialog box is a Query drop-down menu that contains six built-in GREP searches that you can use right out of the box. These searches include:
- Change Arabic Diacritic Marks – For Arabic text, this changes the color of diacritical marks.
- Dash to En Dash – Changes a single dash separated by spaces to an En dash.
- Multiple Return to Single Return – Note that it says multiple. This changes more than one return in a row to one return.
- Multiple Space to Single Space – Changes multiple spaces in a row to a single space.
- Phone Number Conversion (dot format) – Changes phone numbers to a standard format separated by periods.
- Remove Trailing Whitespace – Not a deal breaker if you have spaces at the end of a paragraph, but this search tidies up your text by removing them.
After choosing any one of these built-in GREP searches, the Find what field populates with the regular expression to find the desired text.
In the figure above, the Multiple Return to Single Return option was chosen. Just so you understand a little bit about the content of the Find what field, ~b is the expression for a break character. Putting two of them in a row ~b~b tells GREP to find two break characters in a row, and the + after them indicates that the two break characters can occur one or more times. Brilliant!
The text before running the Multiple Return to Single Return GREP search (left) and after (right).
There you have it! Consider yourself a full-fledged GREP user! Of the six default GREP searches available from the Query drop-down menu, I’m guessing you can take advantage of at least three of them right off the bat. If you have a search dilemma that you think GREP could help you with, leave a comment below. If we hear a good response, I’ll write a post on more detailed GREP searches to help you do your job. Until next time!