is now part of CreativePro.com!

InDesign GREP Essentials: Wildcards

2

This article is part of a series of posts on using GREP in InDesign for beginners

GREP finds patterns based on generalities. That is, you don’t need to know exactly which numbers you’re looking for, just that you are, indeed, looking for numbers. Wildcards come into play when we need to write an expression that looks for any digit, as opposed to the number 3 specifically, for instance. The more you work with GREP expressions, the more wildcards you’ll memorize because you’ll be using them so often in your expressions.

The Number Wildcard

For example, the wildcard that we would need when formatting a phone number, serial number, part number, etc is the one for “any digit.” This is expressed in GREP as \d. As you build out your expression, you may find that you need two (or even more) of a particular wildcard. When looking for two digits, you could write \d\d. In another article, I show you how to simplify this type of expression, but it’s perfectly possible to find a 10-digit string—a North American phone number, for example—with dddddddddd.

Character Wildcards

Looking for a lowercase letter or an uppercase one? Use \l and \u, respectively. One of the first things I noticed when learning GREP was the proliferation of backslashes. In terms of wildcard usage, they are there to distinguish the letter used in its special context from the literal meaning of the letter. Conversely, backslashes are often used when you want to indicate the literal character itself. For instance, probably the most common wildcard you will use is the teeny tiny period (also known as a dot or full stop). A period by itself indicates any character, from a letter to a number to a symbol to a tab space. But if you’re looking for an actual period, then you throw the backslash in front of it. It can get a little confusing, but my modus operandi is simply to throw a backslash in front of an expression that isn’t working, or remove one if one exists.

The Secret GREP Menu

You don’t have to learn all of the wildcards and other GREP expressions because the folks at Adobe have gifted us with a handy resource: The Secret Menu. When you’re creating a GREP expression, there is a little “at symbol” (@) to the right of the various input fields. Click that and you’ll find many of the expressions you’ll need, listed by their name or their function. And lastly, doing a web search will often give you just what you need. When searching, though, remember to indicate you’re looking for GREP in InDesign, since InDesign uses a subset of all that’s available GREP-wise.

InDesign's "secret GREP menu"

InDesign’s “secret GREP menu”

Erica Gamet has been involved in the graphics industry for over 35 years. She is a speaker, writer, trainer, and content creator focusing on Adobe InDesign, Apple Keynote, and varied production topics. She is a regular presenter at CreativePro Week, regular contributor to CreativePro Magazine, and has spoken at Canada’s ebookcraft, Adobe MAX, and Making Design in Oslo, Norway. Find Erica online at the CreativePro YouTube channel, CreativeLive.com and through her own YouTube channel. When she isn’t at her computer she’s probably daydreaming about travel or living in a Nordic noir landscape.

Website
LinkedIn
Instagram
  • Bruce McKillip says:

    Hi —

    I’m using a very simple GREP search/replace to insert a nonbreaking space between any digit and any character. But my document uses lots of OpenType fraction glyphs, and the wildcard (\d) doesn’t find those. Do you know if there’s a GREP expression for those?

    Thanks!
    Bruce

  • Michael Allen Campassi says:

    I have a large document that contents extremely long facebook urls. I need to change them all to a single phrase Find Us On Facebook and delete all the characters after the word facebook. What would that grep expression look like
    Thanks

  • >