Professional Documents
Culture Documents
Find and Replace Text and Other Data in A Word Document 4
Find and Replace Text and Other Data in A Word Document 4
expressions, which are combinations of literal text and wildcard characters. 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. For example, you can use regular expressions to find and remove duplicate
rows from a large table or to transpose a list of names (change them from "First Last" to "Last, First").
Here's a sample you can try. 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.
Josh Barnhill
Doris Hartwig
Tamara Johnston
Daniel Shimshoni
3. On the Home tab, in the Editing group, click Replace 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. Type the following characters in the Find what box. Make sure you include the space between the
two sets of parentheses, and do not include a space at the end.
(<*>) (<*>)
6. In the Replace with box, type the following characters. Make sure you include the space between the
comma and the second slash.
\2, \1
7. Select the names, and then click Replace All. Word transposes the names and separates them with
a comma, like so:
\2, \1
7. Select the names, 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
The document’s content determines most (but not all) of the design of your regular expressions. In the
example above, each item (name) contained two words. If the item contained two words and a middle
initial, you'd use a different expression.
The less than and greater than symbols (< >) mark the start and end of each word, respectively.
They ensure that the search returns a single word.
The parentheses and the space between them divide the words into distinct groups: (first word)
(second word). The parentheses also indicate the order in which you want search to evaluate each
expression.
The slash (\) works with the numbers to serve as a placeholder. (You can also use the slash to find
other wildcard characters. See the next section for more information.)
The comma after the first placeholder inserts the correct punctuation between the transposed
names.
In other words, the expression says: "Write the second word, add a comma, write the first word."
The following examples show you some of the ways that you can use wildcard characters and regular
expressions in Word. For a list of the wildcards you can use, see the section Wildcards for items you want
to find and replace above.