Using Wildcards with Find and Replace in Word
The find and replace options in Word are a lot more powerful than they first appear. You can use the extended options within these functions to search and replace only text that is formatted in a particular way or use wildcards to find and replace multiple related strings all in one go. It is the second of these two capabilities that I am going to discuss here.
There are two ways of entering wildcards into your find and replace fields. Firstly there are a number of wildcards that are always available for you to use in the find and replace fields. Some of these can only be entered in one of these fields while others can be entered in whichever of the two fields that you require. You can access these always available wildcards in one of two ways, either by selecting More at the bottom of the find/replace dialog box and selecting the one that you want from the list that appears when you select Special or by entering the value yourself directly into the field or replace field.
The following table shows the wildcards that are always available like this, what each means, and which of the two fields it can be used in.
| code | meaning | find and/or replace |
| ^- | optional hyphen | find and replace |
| ^# | any digit | find only |
| ^$ | any letter | find only |
| ^& | the found text | replace only |
| ^? | any character | find only |
| ^^ | caret (^) | find and replace |
| ^~ | non breaking hyphen | find and replace |
| ^+ | em dash | find and replace |
| ^= | en dash | find and replace |
| ^a | comment | find only |
| ^b | section break | find only |
| ^c | clipboard contents | replace only |
| ^d | field | find only |
| ^e | endnote mark | find only |
| ^f | footnote mark | find only |
| ^g | graphic | find only |
| ^l | manual line feed | find and replace |
| ^m | manual page break | find and replace |
| ^n | column break | find |
| ^p | paragraph mark | find and replace |
| ^s | non breaking space | find and replace |
| ^t | tab | find and replace |
| ^w | whitespace | find only |
If you selected the More button then you will notice that there is a checkbox in the extended part of the find/replace dialog box labelled Use Wildcards. If you check this option then a further range of wildcards is available for you to use in the find field. As these wildcards are even more powerful than the ones listed above, I will also provide examples of how to use them. Where a range can be entered the values must be in ascending order.
Note that if you need to search for a character that's defined as a wildcard you can type a backslash (\) before the character. For example, type \* to find an asterisk.
| code | meaning | example |
| ? | any single character | b?t finds "bat", "bet", "bit", and "but" |
| * | any string of character | t*n finds "ten" and "tenon". |
| [ ] | one of the specified characters | r[au]n finds "ran" and "run" |
| [-] | any single character in the specified range | [g-p]ight finds "light" and "night". |
| [!] | any single character except the characters inside the brackets | b[!a]t finds "bet" and "bit", but not "bat" |
| [!-] | any single character except characters in the range | l[!a-m]te finds "lute", but not "late" |
| {n} | exactly n occurrences of the previous character or expression | re{2}d finds "reed" but not "red" |
| {n,} | at least n occurrences of the previous character or expression | to{1,} finds "to" and "too" |
| {n,m} | from n to m occurrences of the previous character or expression | 10{1,3} finds "10", "100", and "1000" |
| @ | one or more occurrences of the previous character or expression | lo@t finds "lot" and "loot" |
| < | beginning of a word | <(res) finds "restaurant" and "respite", but not "interest". |
| > | end of a word | (on)> finds "on" and "vision", but not "visionary". |
When you are using wildcards like this you can use parentheses to group the wildcard characters and text and to indicate the order of evaluation. For example, type <(pre)*(ed)> to find "presorted" and "prevented".
There is one more wildcard not mentioned in the above table and this is the \n (backslash number) wildcard. This wildcard is used in the replace field to reorder the values entered in the find field. For example, typing (Jones) (John) in the find field and \2 \1 in the replace field will find "Jones John" and replace it with "John Jones".
With all of these wildcards available the find and replace functions can be used to make the updating of your document much easier. You can even refine the function further by attaching formatting information (eg. find only if its bold) to your search using the Formatting button at the bottom of the extended dialog box.



