Logo: TechTrax...brought to you by MouseTrax Computing Solutions

Wild About Wildcards

by Bill Coan, MVP

How to transform an entire document with a single click of your mouse!

If you're like most users, you're probably quite familiar with Word's Replace command.

Figure01–Image of the Edit menu showing the Replace option highlighted.

Nestled quietly on the Edit menu, this command comes in handy when you get a new boss.

You have two choices: You can take last year's announcement about "Fred," and instantly change it to this year's announcement about "Mary." Or, you can take last year's announcement about Fred being "hired," and change it to this year's announcement about Fred being "fired."

Figure02–The Find/Replace input box.

Either way, it's as simple as pulling down the Edit menu and choosing Replace, then typing a value into the Find what box and another into the Replace with box. After making sure you've entered the proper values, simply click Replace All and your work's done—take a break.

But there's more!

Of course, that's just the tip of the iceberg. The real power of Word's Replace command is hidden—but not hard to find. To see what lies beneath the surface, simply click the More button to display the full dialog box.

Figure03–The Find/Replace input box expanded to show additional options.

The additional power lies not only in the five checkboxes, but also in the Format and Special menus. The Format 3=mousetrax menu lets you find and replace text formats. This menu is worth exploring at your first opportunity. For this article, we'll march ahead to the Special menu and also to the Use Wildcards checkbox.

Figure04–The expanded Find/Replace input box displaying the Special menu characters.

The Special menu is actually four menus in one. How can that be? It's as simple as this: If you click in the Find what box, the Special menu offers a list of items suitable for the Find what box. On the other hand, if you click in the Replace with box, the menu reconfigures itself and offers a list of items suitable for the Replace with box.

Finally, if you place a checkmark in the Use Wildcards checkbox, the menu transforms itself again; this time it shows, respectively, wildcards for the Find what box and wildcards for the Replace with box.

The easiest way to explore wildcard find-and-replace operations is to place a checkmark next to the Use Wildcards checkbox and then use the Special menu to build experimental Find what and Replace with expressions. In fact, you'll learn so much from a little experimentation that all I'm going to do here is dazzle you with a couple of specific examples. Hopefully, that will make you want to fire up Word right away and start putting wildcard find-and-replace operations to work on your documents.


Wildcard Example #1

Problem:
Delete html tags or sgml tags or other bracketed tags (<EXAMPLE>) without affecting other text.

Solution:

  1. In the Find What box, enter the following string: "\<*\>" WITHOUT THE QUOTES.

  2. Leave the Replace With box empty.

  3. Place a checkmark in the Use Wildcards box.

  4. Click Replace all.

Wildcard Example #2

Problem:
Transpose dates from mm/dd/yy to dd/mm/yy.
Example: from 12/17/85 to 17/12/85

Solution:

  1. Enter the following values into the Replace dialog:
    Find What: ([0-9]{1,2})/([0-9]{1,2})/([0-9]{1,2})
    Replace With: \2/\1/\3

  2. Click Replace All and dates are all transformed, including any errant dates where the user left out the leading zero, such as 6/9/98.

Wildcard Example #3

Problem:
Add a decade to the years from 1980 to 1989 without affecting any other years.
Example: Change 1983 to 1993 without affecting 1979 and 1990, etc., etc.

Solution:

  1. Enter the following values into the Replace dialog:
    Find What: 198([0-9])
    Replace With: 199\1

  2. Click Replace All and years from 1980 to 1989 are advanced by a decade.

This is just a taste of what you can do with Word's Wildcard Find and Replace feature. To read a lot more, be sure to check out Microsoft MVP, Graham Mayor's expanded article on the subject at the Microsoft Word MVP's FAQ (frequently asked question) support web site. Here's a direct link to his article: http://www.mvps.org/word/FAQs/General/UsingWildcards.htm.

 

Go up to the top of this page.
This site powered by the Logical Web Publisher (TM): Fast, easy, and affordable content management