The 2020 Guide to Using Word Wildcards
3 September, 2020
By Jack Lyon, the Editorium
Your anguished cry rings out in the middle of the night: “Why, oh why, did I accept this stupid freelance job?” You know the answer: The client offered you twice as much money as you’d ordinarily get for a job like this because the deadline is tight. But now that deadline is looming, and there’s still a lot of work ahead. If only you knew how to use wildcard find and replace!
Using wildcards is not as hard as you might think. In fact, I’m going to give you seven easy wildcard searches you can use right now to help clean up that manuscript and beat that deadline.
Wildcard Search #1: Replacing Double Spaces
Those of us who learned to type on an actual typewriter were taught to put two spaces between each sentence, supposedly to help with readability, and there are still plenty of academics who cling to that outmoded practice. Turning two spaces into one is easy enough: just put two spaces in Microsoft Word’s “Find what” box, one space in the “Replace with” box, and hit the “Replace all” button. Done. Unless, as often happens, old Professor Griggs has been sloppy and sometimes used three spaces in a row. Or, worse, the professor has used multiple spaces to indent paragraphs or do other kinds of formatting. In that case, you’ll need to hit “Replace all” multiple times to clean up the problem. But there is a better solution: Use wildcards. Here’s how:
- Display Word’s “Replace” dialog by pressing CTRL + h on your keyboard. (On a Mac, press CMD + h.)
- In Word’s “Find what” box, type a single space. Then, right after the space, type this:
{2,}
- In the “Replace with” box, type a single space.
- If the “More” button is showing, click it.
- Put a checkmark in the “Use wildcards” box.
- Click “Replace all.”
All those multiple spaces will be replaced by a single space—in one operation!
So what’s the deal with the {2,} wildcard? Simple. It tells Word to find at least two occurrences of whatever precedes the wildcard—in this case, a space. But if you knew that Professor Griggs had used a maximum of five spaces in a row, you could use this wildcard instead:
{2,5}
That tells Word to find from two to five occurrences of whatever precedes the wildcard.
If you use a number without a comma, Word knows to find that specific number of whatever precedes the wildcard:
{3}
Wildcard Search #2: Replacing Double Paragraph Breaks
In my experience, most people using Word have no clue about the right way to add extra space between two paragraphs. (Hint: Use styles with paragraph formatting that specifies “Space before” or “Space after.”) Instead, they just hit the ENTER key however many times it takes to get the amount of space they want, which means you’ll need to clean those up before the document is ready for publication.
The procedure is basically the same as we used to replace double spaces, but there’s a catch. Normally in Word, you’d use the special code ^p to search for a paragraph break, but not with wildcards. If you try, Word will display an error message.
So how do you search for paragraph breaks when using wildcards? Instead of ^p, use the ANSI code ^013. To find multiple breaks, use this:
^013{2,}
In regular language, that means “find any occurrence of two or more paragraph breaks in a row.” All well and good, but there’s a catch. In Word’s “Replace with” box, you must not use ^013; instead, use ^p, which is Word’s code for a paragraph break. That’s right:
Find what:
^013{2,}
Replace with:
^p
Why? Because Word’s paragraph breaks are not the same thing as an ANSI paragraph break (^013). Word stores all kinds of stuff in paragraph breaks (formatting, for example), and an ANSI break is just a character like any other. I’ve occasionally had to work on documents that came from who-knows-where, and my usual wildcard searches wouldn’t work. I finally realized that those documents were using ANSI paragraph breaks rather than Word’s proprietary paragraph breaks. After I replaced the ANSI breaks with ^p, my wildcard searches worked again.
Wildcard Search #3: Make Sure Commas and Periods are “Inside” (Preceding) Ending Quotation Marks
If you’re editing a document using American English, you probably want commas and periods to precede rather than follow closing quotation marks. In other words, instead of this:
“I think; therefore, I am”.
You want this:
“I think; therefore, I am.”
And instead of this:
“I think; therefore, I am”, said Descartes.
You want this:
“I think; therefore, I am,” said Descartes.
To make that happen in a single Find/Replace operation, here’s what you need:
Find what:
^0148([.,])
Replace with:
\1^0148
Let’s take that apart and see how it works. In the “Find what” box, we have ^0148, the ANSI code for a closing quotation mark. (On a Macintosh, the code is ^0211.) Then we have both a period and a comma in square brackets. In the wildcard world, items in square brackets are known as a “range.”
[.,]
A range tells Word to find any one of the characters included in the brackets, so here we’re telling it to find a period or a comma (but not both together). You can include the actual characters that you want to find (as we’ve done here), or you can specify a range of characters by separating them with a hyphen. For example, to find a lowercase a, b, c, or d, you’d use this this range:
[a-d]
Wildcard searches are always case-sensitive, so to find an uppercase A, B, C, or D, you’d need this:
[A-D]
To search for any letter (including accented letters), use this:
[a-zA-Z]
To find any number, use this:
[0-9]
And to find any letter or number, use this:
[0-9a-zA-Z].
But why, you may ask, is our range [.,] enclosed in parentheses?
([.,])
In the wildcard world, items in parentheses are known as a “group,” and their sole purpose in the “Find what” box is so they can be referred to in the “Replace with” box. The first (or only) group in the “Find what” box is referred to by \1 in the “Replace with” box. (If we had two groups in the “Find what” box, we would refer to them as \1 and \2 in the “Replace with” box. You can actually have several groups going at the same time.)
Our “Find what” string, then, is saying “Find a closing quotation mark followed by a period or a comma (as a group).”
^0148([.,])
And our “Replace with” string is saying “Replace whatever is found with whatever in group 1 was found, followed by a closing quotation mark.”
\1^0148
We’re telling Word, “If you find a closing quotation mark followed by a period, replace both with a period followed by a closing quotation mark. If you find a quotation mark followed by a comma, replace both with a comma followed by a quotation mark.” Thus, this:
“I think; therefore, I am”.
becomes this:
“I think; therefore, I am.”
And this:
“I think; therefore, I am”, said Descartes.
becomes this:
“I think; therefore, I am,” said Descartes.
And we did it all in a single Find/Replace operation.
That’s a simple example, but perhaps it’s given you some idea of the power that’s available with wildcards.
Wildcard Search #4: Make Sure Commas and Periods Are “Outside” (Following) Ending Quotation Marks
If you’re editing a document using British English, you probably want commas and periods to follow rather than precede closing quotation marks. In other words, instead of this:
“I think; therefore, I am.”
You want this:
“I think; therefore, I am”.
And instead of this:
“I think; therefore, I am,” said Descartes.
You want this:
“I think; therefore, I am”, said Descartes.
To make that happen in a single Find/Replace operation, here’s what you need:
Find what:
([.,])^0148
Replace with:
^0148\1
By now, you should be able to see exactly what’s going on in that operation, so I’m not going to explain it. You’re starting to get this! And it’s easier than you thought.
Wildcard Search #5: Replacing Hyphens Between Numbers with En Dashes
Most authors use a hyphen between numbers to indicate a page range in a citation, like this:
See pages 342-49.
But for publication, an en dash is needed rather than a hyphen:
See pages 342–49.
Using wildcards, that’s an easy fix.
Find what:
([0-9])-([0-9])
Replace with:
\1^=\2
In this example, we’re using two groups, both with a range of all numbers (from zero to nine), separated by a hyphen.
In our citation:
See pages 342-49.
that “Find what” wildcard string will find this (two numbers joined by a hyphen):
2-4
The “Replace with” wildcard string will produce this (the two numbers that were found, joined by an en dash, which is specified by the ^= code):
2–4
And that will give us our desired result:
See pages 342–49.
Wildcard Search #6: Changing Chicago-Style Number Ranges to Regular-Style Number Ranges
You can use wildcards to do lots of other things with page numbers. For example, let’s say your author has used Chicago-style number ranges (and used hyphens) like this:
See pages 342-49.
But the publisher’s style calls for regular-style number ranges (with en dashes) like this:
See pages 342–349.
Here are the wildcard strings you’d need to do that; the “Find what” string includes three bracketed number ranges in three parenthetical groups, which are referred to in the “Replace with” string with \1, \2, and \3:
Find what:
([1-9])([0-9]{2})-([0-9]{2})
Replace with:
\1\2^=\1\3
The “Find what” string finds a single number (one through nine, in the first group), followed by any two numbers (in the second group), followed by a hyphen, followed by any two numbers (in the third group).
The “Replace with” string inserts the single number found, the two numbers found together, an en dash, the same single number found (using \1 again), and the last two numbers found, giving us this:
See pages 342–349.
Wildcard Search #7: Changing Regular Page Ranges to Chicago-Style Page Ranges
What if you wanted to go the other way, from regular-style numbers to Chicago style? That’s more complicated, requiring three separate Find/Replace operations:
- Numbers that take the form 104-105 need to be converted to 104–5:
Find what:
([1-9])0([1-9])-\10([1-9])
Replace with:
\10\2^=\3
There’s a neat trick going on in that “Find what” string. The first number grouping, ([1-9]), is being referred to by the \1 that follows the hyphen. See it? Just before the 0 there? That tells Word to find (again) whatever was found by the first number grouping. Yes, using \1, \2, or whatever, you can refer to a group in the “Find what” box as well as in the “Replace with” box!
That means when the search hits something like “203-205,” it says, “Hey, my first number group finds 2 [the first number in 203]. Let’s see, is there also a 2 after the hyphen? Yes, there is!”
- Numbers that take the form 104-110 need to be converted to 104–10:
Find what:
([1-9])0([1-9])-\1([1-9])([0-9])
Replace with:
\10\2^=\3\4
- Numbers that take the form 111-112 or 119-120 need to be converted to 111–12 or 119–20:
Find what:
([1-9])([1-9])([0-9])-\1([1-9])([0-9])
Replace with:
\1\2\3^=\4\5
Summary
In this article I’ve given you seven simple wildcard searches you can use to clean up common problems in that manuscript you’re editing. (Okay, so that last one wasn’t so simple.) But, sneaky old me, I’ve also shown you how to use some of the most powerful tools in the wildcard toolbox: number of occurrences {}, ranges [], and groups (). Using those tools, you can fix many kinds of recurring problems.
Ready to learn even more about searching with wildcards? Check out my book Wildcard Cookbook for Microsoft Word (ISBN 978-1434103987).
Here’s a bonus for you: You can download a free wildcard reference sheet from the Editorium website:
http://www.editorium.com/wildcard_reference.pdf
I recommend printing it on 8.5-by-11-inch cardstock, both front and back (each side will be different), and then cutting the cardstock in half lengthwise (at 4.25 inches). That will give you a handy reference card to keep by your computer and another card to give to a friend.
Continue Your Wildcard Education: Free Download!
Ready to learn even more about Word wildcards?
Download the Wildcard Cookbook for Microsoft Word by Jack Lyon today!
In the Wildcard Cookbook for Microsoft Word, you’ll learn how to build your own wildcard searches with detailed screenshots and instructions. You will gain the confidence you need to implement these time-saving strategies in your work. And if you love the idea of wildcards but are not ready to write your own, the Wildcard Cookbook includes real-world examples that you can simply copy and paste!
This ebook, a $10 value, is available free. Get it while you can. Download your copy now!