Join Michael Murphy for an in-depth discussion in this video What is GREP?, part of Learning GREP with InDesign.
Before we can start working with GREP, let's first to find exactly what GREP is. GREP started as a command line text searching utility for the Unix Operating System. Originally, it was an acronym for the task of globally searching for a regular expression and printing the results, and the command line for that was GREP, hence GREP. Over time, that acronym has also been translated as General Regular Expression Parser among other interpretations, but whatever variation of the name is used, the regular expression part never changes.
So what's a regular expression and what is parsing? A regular expression is a means of describing text, text patterns, or conditions within text. Most regular expressions don't actually have to contain any literal text at all. Text in a regular expression is described by what's called metacharacters, which stand in for actual characters. You can use individual metacharacters, like any digit, to search for one specific thing or combine many different metacharacters into an expression that describes a pattern of text.
Parsing is the process of sifting through text to find the patterns described by that regular expression. Although GREP's origins are in computer programming, over the years it's found its way into many text-editing applications, which exposed it to many more nonprogrammers. Now, GREP has been built directly into Adobe InDesign, which has made it a mainstream technology available to designers, production artists, and document producers, who can really benefit from its capabilities. It may look a bit intimidating at first, but GREP is not as formidable as it seems once you understand its basic concepts.
And when you see how much time it can save you, you'll find its well worth the learning curve.
- Using metacharacters, the building blocks of GREP
- Describing text that may not exist with zero operators
- Applying multiple character styles to the same text with GREP styles
- Eliminating orphaned words at the ends of paragraphs
- Preserving and recalling subexpressions
- Customizing a GREP-based text cleanup script for long documents
Skill Level Intermediate
Q: In the “Dynamically fixing orphaned words with GREP” tutorial the author uses the term:
In an earlier course the author described the + (one or more) modifier as unusable in a lookbehind or lookahead i.e. (?<=.+). What's the difference here?
A: The limitation mentioned in an earlier movie referred only to positive lookbehind and negative lookbehind. I was able to use the one or more times (+) metacharacter in the positive lookahead portion of the expression because that limitation doesn't affect either positive or negative lookahead. It's only when looking backward that GREP ignores the repeat metacharacters.