wildcard character

To start, let's define a couple of terms:

* A wildcard character is a keyboard character that you can use to represent one or many characters. For example, the asterisk (*) typically represents one or more characters, and the question mark (?) typically represents a single character.
* In our case, a regular expression is a combination of literal and wildcard characters that you use to find and replace patterns of text. The literal text characters indicate text that must exist in the target string of text. The wildcard characters indicate the text that can vary in the target string.

That may seem a bit abstract, but you've seen (and most likely used) wildcard characters and regular expressions since you first began computing. For example, the Open dialog box (on the File menu, click the Open command) uses the asterisk wildcard character extensively:

Wildcard characters in the Open dialog box

And, if you ever used the MS-DOS operating system, you probably used a command and a simple regular expression to copy files:

copy *.doc a:

That command uses the asterisk wildcard character and the .doc literal text string to copy a set of Word documents to hard disk drive A. If you look around a bit, you'll see that Microsoft Windows® and the Microsoft Office applications use wildcard characters everywhere.

The steps in this section explain how to use a regular expression that transposes names. Keep in mind that you always use the Find and Replace dialog box to run your regular expressions. Also, remember that if an expression doesn't work as expected, you can always press CTRL+Z to undo your changes, and then try another expression.
To transpose names

1. Start Word and open a new, blank document.
2. Copy this table and paste it into the document.

Josh Barnhill
Doris Hartwig
Tamara Johnston
Daniel Shimshoni
3. Press CTRL+F to open the Find and Replace dialog box.
4. If you don't see the Use wildcards check box, click More, and then select the check box. If you don't select the check box, Word treats the wildcard characters as text.
5. Click the Replace tab, and then enter the following characters in the Find what box. Make sure you include the space between the two sets of parentheses: (<*>) (<*>)
6. In the Replace with box, enter the following characters. Make sure you include the space between the comma and the second slash: \2, \1
7. Select the table, and then click Replace All. Word transposes the names and separates them with a comma, like so:

Barnhill, Josh
Hartwig, Doris
Johnston, Tamara
Shimshoni, Daniel

At this point, you may wonder what to do if some or all of your names contain middle initials.

Labels: ,

Subscribe in a reader


Post a Comment

Links to this post:

Create a Link

<< Home