Finding "Whole Words Only" with Wildcards

If you often use wildcards with Microsoft Word’s Find and Replace feature, you probably know that Word won’t let you specify “Find whole words only” when the “Use wildcards” option is checked. This is more than an annoyance; sometimes you really *need* to be able to find whole words only while searching with wildcards.

To learn more about wildcard searching, see these back issues of Editorium Update:

http://www.topica.com/lists/editorium/read/message.html?mid=1705963026

http://www.topica.com/lists/editorium/read/message.html?mid=1706069286

http://www.topica.com/lists/editorium/read/message.html?mid=1706167662

http://www.topica.com/lists/editorium/read/message.html?mid=1706267069

http://www.topica.com/lists/editorium/read/message.html?mid=1706365638

http://www.topica.com/lists/editorium/read/message.html?mid=1706458823

Last week’s Readers Write column offered one solution to the “Find whole words only” problem: Include a space before and after the words you’re looking for. Of course, as the column noted, not every word begins or ends with a space. Words are often preceded or followed by quotation marks, dashes, and other characters, which would require multiple searching and replacing.

That suggests another solution: Use a wildcard “group” that includes every possible character that might precede or follow a word. For example, if we were searching for the word “bet,” we could use a group like this before the word in the “Find What” box:

[ “-_/]

That group (preceding “bet”) would find the following text:

bet [preceded by a space]

“bet

-bet

_bet

/bet

We’d need a similar group after the word:

[ .,;:!”-_/]

That group (following “bet”) would find the following text:

bet [followed by a space]

bet.

bet,

bet;

bet:

bet!

bet”

bet-

bet_

bet/

So our entire “Find What” string would look something like this:

[ “-_/]bet[ .,;:!”-_/]

So far so good, but there ought to be an easier way. How about using a group to specify what *not* to find before and after the word we’re looking for–like this:

[!A-z]bet[!A-z]

That string tells Word to find the word “bet” preceded and followed by any nonalphabetic character, which would certainly omit “bet” as part of another word. If we wanted to find “bet” both capped and lowercased, we could use this string:

[!A-z][b,B]et[!A-z]

These approaches are clever, and they will certainly work. In some situations, they (or variations of them) may be the best way to go, which is why I’ve included them here. However, we also need to remember that Microsoft Word includes a wildcard code for “beginning of word” (<) and "end of word (>).”

So, if we needed to find the whole word “bet” in a wildcard search, we could put this in the “Find What” box:

That string would find “bet” but not “better” or “sorbet”–in other words, it would find “bet” as a whole word only!

Using < and > is probably the most elegant (and the easiest) way to find whole words only while searching with wildcards.

Thanks to Pamela Angulo, Michael C. Coleman for contributing to this article.

_________________________________________

READERS WRITE

After reading last week’s article about resizing drop-down lists on toolbars, Steve Hudson wrote:

“I have only one horizontal toolbar which has Style, Font (so I can tell which gallery I am using at the moment), and the file path. I have stretched the file path to its max, which is quite long. I also included undo/redo and highlight on this toolbar as their drop-down nature means they have a non-standard width.”

This is a great example of personalizing Word; this toolbar (with its resized lists) sounds most useful. Thanks, Steve.

Pamela Angulo wrote:

“I recently started working in Word 2000. Some things, I like (e.g., I can copy and paste passages with revision marks, and the marks are preserved–yay!). But I got used to working with Draft Font in Word 97, which was a nice sans serif screen font; in Word 2000, the Draft Font appears to be the same as the Default: Times New Roman. (Ick–where’s the value added in that?) What’s more, in Word 97, italicized text is denoted with an underline; in Word 2000, italicized text is not differentiated in any way. [This is a known “issue” in Word 2000.]

“I’m frustrated. Is there any way to customize the screen font used in Draft Font? If not, is there another way to specify a screen-only font? (My concern is that I often work with files that contain symbols, so a simple Ctrl+A, Format/Font is not an option if I ever want those symbols back.) Is there another option that I haven’t thought of?”

Do you, gentle reader, have a solution to Pam’s problem? If so, please send it here: mailto:hints [at symbol] editorium.com.

_________________________________________

RESOURCES

The Electric Editors Web site offers macros, email list discussion groups, links to reference tools, and many other resources for editors, especially those who work on the computer. The home page notes, “If you’re a professional editor (or anyone with an interest in preparing the written word for publication), the Electric Editors are here to help. On these pages you’ll find a comprehensive collection of resources to help you in your work.” You can visit the site here:

http://www.electriceditors.net

This entry was posted in Editing. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

You must be logged in to post a comment.

  • The Fine Print

    Thanks for reading Editorium Update (ISSN 1534-1283), published by:

    The EDITORIUM, LLC
    http://www.editorium.com

    Articles © on date of publication by the Editorium. All rights reserved. Editorium Update and Editorium are trademarks of the Editorium.

    You may forward copies of Editorium Update to others (but not charge for it) and print or store it for your personal use. Any other broadcast, publication, retransmission, copying, or storage, without written permission from the Editorium, is strictly prohibited. If you’re interested in reprinting one of our articles, please send an email message to editor@editorium.com

    Editorium Update is provided for informational purposes only and without a warranty of any kind, either express or implied, including but not limited to implied warranties of merchantability, fitness for a particular purpose, and freedom from infringement. The user (you) assumes the entire risk as to the accuracy and use of this document.

    The Editorium is not affiliated with Microsoft Corporation or any other entity.

    We do not sell, rent, or give our subscriber list to anyone.