I’ve been playing around a lot lately with wildcards in Word, and I’ve developed quite a few custom macros that I use in my editing work. It’s taken a bit of practice, but I feel pretty confident now about my knowledge of wildcards and how to use these to quickly find and replace text in the manuscripts I work on.

For those who may not know, wildcards are special characters that represent the text you wish to find in Word. If you use the same searches repeatedly to find and replace text, you can record a macro that will allow you to make changes with the click of a button.

In Adobe InDesign, GREP (global regular expression print) is basically the equivalent of Word’s wildcards feature. The characters are different, but the patterns are very similar. GREP patterns can also be used in paragraph styles. And that’s what this boils down to: knowing how to recognize patterns and translate these into code that can speed up your work.

Below I’ve listed some examples of common issues you may come across while editing. I’ll admit I used a few examples from Jack Lyon’s excellent book, Wildcard Cookbook for Microsoft Word, for inspiration. I highly recommend reading this book if you’re interested in learning more about using wildcards in Microsoft Word.

The An American Editor blog also has some great posts from Jack about improving your editing and writing workflow, and you can find some great resources on the Editorium, which he founded.

Note: You should always be careful about using “Replace All”—it’s easier to click on one button to make global changes instead of taking the time to examine each change before clicking “Replace,” but using “Replace All” can result in unintended changes in your file, and you may not notice where other replacements have been made.

Also, while working in Word, be sure to check “Use wildcards” in the Find and Replace dialog box. If you don’t, your search won’t work correctly.

In InDesign, be sure that you’re working in the GREP tab of the Find/Change dialog box.

Problem 1: Sorting author names by last name first

A common change editors need to make is switching the order of first and last names in a reference list or within the text. Let’s say you wanted to change a list of names like the following:

John Smith

Denise Foster

Elizabeth Williams

Jane Austen

You might want it to look like this instead:

Smith, John

Foster, Denise

Williams, Elizabeth

Austen, Jane

How to do this in Word using wildcards

Find
([A-z]@) ([A-z]@)^013

Replace
\2, \1^p

How to do this in InDesign using GREP

Find
(\u\l+) (\u\l+)

Replace
$2, $1

Problem 2: Shortening citations with “et al.”

I frequently use wildcard searches to revise reference lists to conform to a certain style. You might have a reference entry with author names that look like this:

Smith J, Foster D, Doe J, Wilson R, et al.

Williams E, Snyder A, Frost A, Austen J, et al.

But your client may prefer them to look like this, with only three authors listed followed by “et al.”:

Smith J, Foster D, Doe J, et al.

Williams E, Snyder A, Frost A, et al.

How to do this in Word using wildcards

Find
([!^013]@, [!^013]@, [!^013]@, )[!^013]@, (et al.)

Replace
\1\2

How to do this in InDesign using GREP

Find
([^\r]+, [^\r]+, [^\r]+, )[^\r]+, (et al.)

Replace
$1$2

Problem 3: Replacing hyphens in page ranges with en dashes

Another common issue is page ranges that use hyphens rather than en dashes. You might need this list . . .

110-124.

75-89.

16-23.

34-47.

. . . to look like this instead:

110–124.

75–89.

16–23.

34–47.

How to do this in Word using wildcards

Find
([0-9]@)-([0-9]@).

Replace
\1–\2.

How to do this in InDesign using GREP

Find
(\d+)-(\d+).

Replace
$1–$2.

Note: As I mentioned earlier, be careful when using “Replace All.” I’ve found that this is generally a safe change to make globally, but it can cause issues with DOI numbers that include hyphens.

Problem 4: Adding spaces between initials (APA style)

Another common issue editors come across is the spacing used with initials. Some styles call for initials to be closed up; some call for a space between the letters. You may have a list like this:

Brown, A.C.

Smith, J.L.

Foster, D.E.

But it needs to look like this:

Brown, A. C.

Smith, J. L.

Foster, D. E.

This can be easy to miss and time-consuming if you are editing a reference list without the help of any find-and-replace operations.

How to do this in Word using wildcards

Find
([A-Z].)([A-Z].)

Replace
\1 \2

How to do this in InDesign using GREP

Find
(\u.)(\u.)

Replace
$1 $2

Problem 5: Adding commas before “&” in citations and references (APA style)

Yet another problem you may come across is adding or removing punctuation throughout a reference list. You may need to add commas around certain elements of a reference entry. Let’s say you have a list like this:

Smith, A. B. & Gordon, D. J.

Doe, J. B. & Smith, L. M.

But you need to add commas around the initials like this:

Smith, A. B., & Gordon, D. J.

Doe, J. B., & Smith, L. M.

How to do this in Word using wildcards

Find
( [&])

Replace
,\1

How to do this in InDesign using GREP

Find
( &)

Replace
,$1

These are just five examples of some common issues you may encounter while editing a manuscript. There are thousands of variations and combinations of these searches you can use to speed up your workflow in both Word and InDesign. Learning how to effectively use wildcards and GREP takes time and practice, but it’s worth it!

I’d love to hear from readers! Do you have other examples? Could you speed up your workflow by using wildcards or GREP for any of your current processes?

4 thoughts to “Fun with Wildcards and GREP

  • Jess Beebe

    Super useful — thank you for this!

    Reply
  • Linda Wieland

    This is a great post! I’ve never tried using the wildcard search (it looks scary) but I can definitely see how it could save lots of time and repetition. I’ve bookmarked this page for future reference. Thanks!

    Reply
    • Denise Foster

      Thank you! I know it seems scary, but with a little bit of practice, learning how to use wildcard searches does get easier, I promise. And it can definitely help you save time in the long run! Thanks for commenting!

      Reply

Leave a comment

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

Subscribe to my free biweekly newsletter to get my FREE Blog Promotion Checklist for Freelance Editors! You’ll also receive the latest news about my business and great content from other editorial pros and freelancers.