Felgall ClubSite

Just launched is my new site Felgall ClubSite. Pages there describe what ClubSite is and how much it will cost you. A demo site will be added soon and I am look... (more)

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.

codemeaningfind and/or replace
^-optional hyphenfind and replace
^#any digitfind only
^$any letterfind only
^&the found textreplace only
^?any characterfind only
^^caret (^)find and replace
^~non breaking hyphenfind and replace
^+em dashfind and replace
^=en dashfind and replace
^acommentfind only
^bsection breakfind only
^cclipboard contentsreplace only
^dfieldfind only
^eendnote markfind only
^ffootnote markfind only
^ggraphicfind only
^lmanual line feedfind and replace
^mmanual page breakfind and replace
^ncolumn breakfind
^pparagraph markfind and replace
^snon breaking spacefind and replace
^ttabfind and replace
^wwhitespacefind 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.

codemeaningexample
?any single characterb?t finds "bat", "bet", "bit", and "but"
*any string of charactert*n finds "ten" and "tenon".
[ ]one of the specified charactersr[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 bracketsb[!a]t finds "bet" and "bit", but not "bat"
[!-]any single character except characters in the rangel[!a-m]te finds "lute", but not "late"
{n}exactly n occurrences of the previous character or expressionre{2}d finds "reed" but not "red"
{n,}at least n occurrences of the previous character or expressionto{1,} finds "to" and "too"
{n,m}from n to m occurrences of the previous character or expression10{1,3} finds "10", "100", and "1000"
@one or more occurrences of the previous character or expressionlo@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.

 

This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow
Donate