in Wildcards

Three Wildcard Secrets

So, you’ve been using wildcards with Microsoft Word’s Find and Replace feature to save time and ensure consistency as you edit the plethora of freelance work that’s bombarding your inbox. Excellent. But even if you’re getting pretty good at using wildcards, there are actually a few secrets that even many experts don’t know. Maybe you’ll find them useful.

Secret #1

Using the wildcard range [A-z] to find any uppercase or lowercase letter will not find accented letters. Take, for example, the word résumé. [A-z] will find the r, s, u, and m in that word, but it will skip over the two occurrences of é. Go ahead, try it. I’ll be here when you get back.

If you actually want to skip over accented letters, [A-z] might come in handy sometime, but that will rarely be the case. To find all letters, both accented and unaccented, use the wildcard range [A-Za-z] instead. Also, as you might expect, [A-Z] finds both accented and unaccented capital letters, and [a-z] finds both accented and unaccented lowercase letters.

Okay, so [A-z] skips over accented characters; that suggests the idea that we could use a variation on that range to find only accented characters. How? Add an exclamation mark at the beginning of the range, which tells Word to find any character except what is in the range. The modified range looks like this: [!A-z]. Again, using the word résumé, [!A-z] finds the two occurrences of é but skips over r, s, u, and m. If you need to find accented characters, now you know how.

Secret #2

In a wildcard search, you can’t search for Unicode characters using numeric codes (such as ^u945), but you can copy Unicode characters from a document and paste them into Word’s Find box. You can even search for a range of Unicode characters. For example, the range [?-?] from the Greek alphabet (lowercase alpha through omega) finds every character in the Greek greeting ???? ???. You can see the range of characters in various languages by clicking Word’s Insert tab and then the Symbol button on the ribbon:

For example, here, in order, are some of the Cyrillic characters available in Word:

If you need to find any (unspecified) Unicode character in a document, you can use this not range:

[!^000-^255]

That works because 127 is the upper limit on ASCII characters and 255 is the upper limit on ANSI characters. This wildcard string excludes them both, so anything it finds must be Unicode.

Secret #3

You can use the search code ^p to search for paragraph breaks in a regular search, 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 ^013. All well and good, but here’s the real secret: In Word’s Replace box, you must not use ^013; instead, use ^p. That’s right:

Find what: ^013

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. The solution? Once again:

Find what: ^013

Replace with: ^p

After I replaced the ANSI breaks, my wildcard searches worked again.

Bonus Secret

Microsoft Word’s wildcard search engine uses a modified version of what is widely known as RegEx—short for “regular expressions.” RegEx is more powerful than Word’s version of it, but if you’re feeling geeky, you can actually use RegEx in Word—not in Word’s Find and Replace dialogs but in a macro. If you’re interested, you can learn more here:

http://www.regular-expressions.info/vb.html

I hope you find these wildcard secrets useful. If you’re just getting started with wildcards, please check out my in-depth book on the subject, Wildcard Cookbook for Microsoft Word (ISBN 978-1-4341-0398-7), available at Amazon, Barnes & Noble, and other purveyors of fine technical literature.