Finding and replacing characters using wildcards


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.


>> READ MORE …Finding and replacing characters using wildcards


About quinten

Practitioner of Specialized Kinesiology, The Netherlands
This entry was posted in find | replace, Word. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s