Home » Questions » Computers [ Ask a new question ]

Wildcards in Word

Wildcards in Word

I know little of wildcard usage in word.

Asked by: Guest | Views: 36
Total answers/comments: 1
Guest [Entry]

"Wildcards are like the blank pieces in Scrabble, or like the Jokers you can use in some card games to stand in for any card. You are perhaps already familiar with the “” and “?” wildcards from file matching: In the File + Open dialog, you can display all files with the extension “.doc” by typing “.doc”, or all files “01062001.doc”, “01072001.doc”, “01122001.doc”... by typing “01??2001.doc”.

But the wildcard feature in Word goes way beyond that, and can be very powerful.

To begin, you must first turn Wildcards on in the Find/Replace dialog. To do so, bring up the Find dialog, click More and check Use wildcards. In a macro, set .Find.MatchWildcards = True. If you do not do this, Word treats the wildcard characters as if they were ordinary text.

As we'll see later, you can define ranges [], groups (), repeats @, {}, anchors < > and exceptions !. With these regular expressions you can search for patterns in your text that have certain things in common (some pattern: for example, that they only contain certain characters, or a certain number of characters).

Note: Word uses “lazy” pattern matching: this means it will quit matching as soon as possible. Most Unix tools use “greedy” pattern matching (the algorithm tries to match as much text as possible), so if you have used such tools, beware!

The secret of using wildcard searches is to use a “pattern” that identifies the string of text that you wish to find, and ignores everything else. Wildcards are used to represent the characters or sequences of characters in that string.

Because different combinations of characters can be represented by a variety of wildcard combinations, there is often more than one way of identifying a particular string of text within a document. How you choose to represent that group of characters is therefore often a matter of individual preference; and the context of the text within the document will to a great extent dictate the most suitable combination to use on a particular occasion.

The following is a list of the characters that have a special meaning in wildcard searches ( [ ] { } < > ( ) - @ ? ! * \ ).

Note: wildcard searches are case sensitive.

It doesn't help that the list of wildcard characters in Word's Help files is almost impossible to find! The wildcard characters are all listed and described in this article, but if you need to find them in Help, the topic is called: “Type wildcards for items you want to find”. But you can't get to that article directly; you must first find the topic: “Fine-tune a search by using wildcard characters”, which contains a link to it!

Zen tip: when using wildcard searches: don't wrinkle your brow or bite on your tongue while thinking it through – you have to keep up a regular expression. :-|"