Using Wildcards to Ensure Commas and Periods Are Inside Quotation Marks
3 September, 2020
By Jack Lyon, the Editorium
Are you getting the most you can from Microsoft Word? Wildcard search is one of the most powerful features in Word. You can use it to quickly find errors and make changes throughout a document in a matter of seconds. However, wildcards can be complicated. In this article, learn how to use Word wildcards to ensure commas and periods are inside quotation marks.
Using Wildcards to 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.
Continue Your Wildcard Education: Free Download!
Ready to learn even more about Word wildcards?
Download the Wildcard Cookbook 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!