Getting a Grip on InDesign’s GREP
Erica Gamet
El Paso, Texas
The Art Institute of California
2950 31st St.
Santa Monica, CA 90405
January 21, 2016
7:00–10:00 p.m.
Does the mere mention of the foreign-sounding GREP send your heart racing? Do you just pretend it doesn’t exist or think it’s over your head? As a designer, you owe it to yourself to discover ways of using GREP to help automate and speed up your workflow. Whether you end up creating GREP expressions on your own, or use the built-in options, you’ll wonder why you waited so long to explore the world of GREP.
Location and Parking
The January meeting will be held at The Art Institute of California, a new location for us, but one that is familiar to those who attend other user groups (LA Web Professionals Group, LAdobe, Adobe Illustrator User's Group LA, among others). Validated parking is free. Bring your ticket to the receptionist who will validate your ticket and direct you to the room.
Meeting Notes
By Alvin Takamori
Kicking off 2016 the Los Angeles InDesign User Group met on January 21st at The Art Institute of California in Santa Monica. A nice crowd filled the classroom and they were in for a real treat. Donuts! We also had a really special guest speaker in Erica Gamet. Proving that if enough people attend and buy some raffle tickets, we can have nicer snacks and bring great presenters from out of state.
Erica is an expert on Adobe InDesign, Illustrator, and Apple Keynote. She conducts training for individuals and corporations and regularly contributes to InDesign Magazine and CreativePro.com.
On this night Erica shared her knowledge of GREP expressions for InDesign. GREP is a command line utility originally written for the UNIX operating system. It's function was to Globally search for matches to a Regular Expression and Print. In other words, it could look through a lot of text for something that matches a recurring pattern.
For many people, the initial response to GREP is to think computer programming and run away. Erica's goal was to break through that fear and bring some understanding as to how useful GREP can be.
In InDesign one place to access GREP is to go to the Edit menu and select Find/Change. The key to GREP is to recognize frequent patterns in the text. Look for the patterns you want to change and find the GREP characters to describe the patterns. That description goes into the Find box. Then create the GREP expression to describe how you want the text to look and that goes into the Change box. Admittedly, this can be a trial and error process. When you hit the Find Next button, you can jump through text, from one section to the next section that the change is applied. This way you can see if the correct change is taking place.
There are some GREP characters that are basically computer commands, which are helpful to learn. But before you throw your hands up and scream, “That's too complicated!” go to ericagamet.com and look under the Tips and Tricks menu to find her GREP Quick Reference Chart. There are a few basic characters that you can start with to get a sense of how they work.
The backslash \ is a key symbol. It appears in front of many letters and symbols to convert them into meaningful GREP characters. For instance \d represents “any digit”. In other words, it’s any number. \l represents any lowercase letter and \u is any uppercase letter. \w is any word. \s is a space between words and \t is a tab. If you actually needed a backslash, in GREP that would be represented by adding another backslash \\.
On her website, Erica breaks down some of these GREP symbols into categories. There are characters that represent objects like a number, a letter, a word, or a space, etc. Then there are characters that represent locations like the beginning or end of a word, paragraph, or story. Other symbols indicate how many times an item appears in a sequence. Another group consists of symbols like parentheses to group expressions and brackets to create a set of characters.
Erica Gamet proceeded to run through a series of examples demonstrating how GREP could be used. She showed how GREP expressions could be used to automate the conversion of the last two digits (representing cents) of any monetary amount and convert them into superscript. You could convert type framed by quotation marks into italics and remove the quotes. That’s a notable aspect of using GREP. It gives you the ability not only to alter type, but to remove things.
GREP could also be used to convert multiple returns into a single return and multiple spaces into a single space. One way to express multiples in GREP language is to add a plus + symbol. For instance, ~b~b+ means two line breaks or more. A question mark indicates zero (the pattern doesn’t exist) or it occurs one time. Combine the two symbols +? to create a GREP meaning zero or more times with the shortest match. Brackets also convey repetition. The expression {2} means something repeats twice. Adding a comma {2} changes the meaning to repeats two or more times. Add another number to place a limit. For instance {2,4} means something repeats 2,3, or 4 times.
Square brackets are also very useful in GREP language for creating sets. For example, [1-4] means look for numbers 1 through 4. But if you move the hyphen and create this [-14]; it means look for a hyphen, or a one, or a four. If you create this set [aeiou], it means look for all the vowels.
A pike symbol, which is a straight vertical line, means ”either or”. For instance, grey|gray means find grey or gray. The same idea could also be written as gr(e|a)y. Find an “e” or an “a” with “gr” in front and a “y” after it.
In another example, Erica demonstrated how to make changes to a list of presidential names. Using parentheses, she created groups of GREP expressions representing the first name, the last name and if it exists, the middle name or initial. Then in the Change box she could rearrange it to put the last name first. In GREP language, it’s written as $3 $1 $2. The dollar symbol in front of numbers indicates a grouping, first group, second group, etc.
Next there was a demonstration of how to write a GREP expression that searches for the various ways that people write telephone numbers and converts them into a single format.
Another interesting aspect of GREP is the ability to look for patterns in the text, but instead of changing those patterns, using them as indicators to find neighboring text to change. Referred to as Positive or Negative Look Ahead or Look Behind. A Positive expression means if you find this pattern, change the text in front of it or behind it. Negative means, if you do not find the pattern then change the text. For instance, going back to the first example, if you were changing the last two digits representing cents of a monetary amount to superscript, you could use a Positive Look Behind. It would be written in GREP characters as (?<=) For this example, you want to look for the two digits behind a period. So the GREP expression would be written as (?<=\.)\d\d
Erica went on to demonstrate how GREP expressions could be used to create bulleted lists, footnotes, automate the application of styles, and even apply a graphic.
Admittedly, learning the vocabulary of GREP can be a bit intimidating. However, there are information sources like Erica Gamet’s website and someone she recommended, Peter Kahrel, along with Adobe’s site. They have lists of GREP symbols and expressions. Even if you don’t know the meaning of the specific characters, you can still go to these websites and others and just look for what you want to do. Want to change a list of phone numbers into one format? Just lookup that process and copy the expressions into the Find and Change boxes.
There seems to be a lot of willingness to share GREP expressions. In fact, although I heard this second hand and don’t know the details, Erica gave an example of applying a stlye of bold using a Positive Look Ahead with a colon as the marker. She learned this expression from someone who happened to be in attendance at our meeting. I think it was Luis Madrigal. If I have this wrong, I apologize, but it provides an axample showing that you don’t have to reinvent the wheel. A lot of smart people have already created many useful GREP expressions that they’re willing to share.
As you can see, Erica Gamet knows a lot about GREP and in a few hours she shared a lot of information. She also did this in such an engaging way that the people who attended filled the opinion forms with words like, “great,” “excellent,” “awesome,” “informative,” “knowledgeable,” “terrific,” etc. If you were there, you know what they meant. If you were not there, you missed out.
Farthest Attendee
The person who travels the farthest specifically to attend the meeting will receive a 6 months subscription to InDesign Magazine. Value $30.00. You need to prove to us that you traveled farthest to attend this meeting. Having recently moved to the area from somewhere else won't cut it. Be prepared to show us indication of your current residence—perhaps a driver's license or a utility bill. Decision of the administrators of the Los Angeles InDesign User Group is final. Winner — Douglas Wade
Raffles
LAIDUG is supported by raffles of donated prizes. No one is required to participate in the raffles. Raffle tickets are: 1 for $3, 2 for $5, 5 for $10, 11 for $20, 24 for $40, 32 for $50 and 65 for $100. All major credit cards are accepted.
Raffle Prizes and Winners
FREE PRIZE: Free Allary-brand touch screen stylus to the first 20 people who purchase at least one raffle ticket. Assorted colors.
eDocker CREATE! 6 month subscription. Value $774.00 Winner — Barbara Fier
Stock Layouts. Full access to Stock Layout template library. 3 month subscription. Value $299.00 Winner — Jeffrey Schimsky
Markzware. Any single product. 12 month subscription. Value $199.00 Winner — Douglas Wade
Expo Creative Asset Manager for Mac from Insider Software. Value $149.00 Winner — Barbara Fier
Font Agent Pro 6 from Insider Software. Value $99.95 Winner — Barbara Fier
InMotion Hosting. Web hosting and free domain. Value $90.00 Winner — Barbara Fier
DTP Tools Cloud for InDesign. 6 month subscription. $77.40 Winner — William Baughman
Fotolia. 3 month subscription. 5 images per month. Value $50.00 Winner — Barbara Fier
TypeDNA. Font management software. Value $49.00 Winner — Douglas Wade
Digital-Tutors. 1 month subscription. Value $29.00 (two raffles) Winners — Barbara Fier, Laurie Miller
LA Web Professionals Group meeting tickets. Value $7.99 (four raffles) Winners — Chip Reuben, Susy Reuben, Douglas Wade, Bing Wong
Note: Barbara Fier bought a lot of raffle tickets.
About the Presenter

Erica Gamet
Erica Gamet has been involved in the graphics industry for nearly 30 years. She is a speaker, writer, and trainer, focusing on Adobe InDesign and Illustrator, Apple Keynote and iBooks Author, and other print- and production-related topics. She is a regular contributor to InDesign Magazine and CreativePro.com, has been a speaker at the InDesign Conference, PePcon, ebookcraft in Canada, and Making Design in Norway; and she offers online tutorials on CreativeLive.com and through her own YouTube channel.