Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Searching for Characters.

Searching for Characters

Written by Allen Wyatt (last updated October 19, 2024)
This tip applies to Word 97, 2000, 2002, and 2003


If you have enabled pattern matching in Word, you can easily specify the exact characters you want to search for. This is done by enclosing the characters in square brackets. For instance, if you want to search for an uppercase A, you would specify this as [A]. If you wanted to search for other characters in addition to the A, you would place them in the brackets as well. For instance, [AEIOUaeiou] searches for all vowels, in either upper- or lowercase.

You can also specify a range of characters you want to search for within the brackets. For example, if you want to search for any digit, you could search for [0-9]. This will match any single digit between 0 and 9. Ranges, of course, can be combined with other characters to find specific characters. Thus, you could specify [A-E0-4] and Word would find only the characters A, B, C, D, E, 0, 1, 2, 3, and 4.

You should note that a pair of square brackets is used to denote a single character to be matched. If you want to find a sequence of characters, then you need to use multiple brackets. For instance, let's say you have a document that has some part numbers in it. These are designated by your company as the characters PN- followed by a single uppercase letter between A and D, followed by a single digit, followed by any uppercase letter of the alphabet. To search for these, without returning other easily confused sequences, you would use PN-[A-D][0-9][A-Z] as your search string. This returns sequences of three characters and only three.

Another helpful modifier to use within the brackets is the exclamation point. This is the same as saying "not" or "anything except." For instance, if you wanted to match any character except lowercase vowels, you would use [!aeiou]. This character must be used at the beginning of the characters within the brackets. Thus, [!abc] is valid, whereas [abc!def] is not. This really does make sense, since [!abc] is logically correct whereas [abc!def] is logically inconsistent.

Pattern matching in Word also understands that a question mark is a placeholder for a single character and an asterisk is a placeholder for any number of characters. In other words, if you searched for n?t, Word would find nut, not, and net. If you instead searched for n*t, those three words would be matched as well as neat, next, and the portion of "pattern matching" between the n (in pattern) and the t (in matching).

If you wanted to actually search for a hyphen, an exclamation point, a question mark, an asterisk, a bracket, a brace, the greater-than character, the less-than character, the at sign, or parentheses (all of which have special meaning), simply precede the character with a back slash (\). For instance, if you wanted to search for characters used to end sentences (period, question mark, and exclamation mark), you would enter your specification as [.\?\!].

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (1184) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Searching for Characters.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Setting Up Multi-page Columns

Do you need a page layout that features columns that progress vertically across pages instead of horizontally across a ...

Discover More

Removing All File Properties

Want to get rid of any properties you've created for a document? You can do so by using the short macro described in this ...

Discover More

Selecting All Visible Worksheets in a Macro

Do you need your macro to select all the visible worksheets (and just the visible ones)? It's not as easy as it sounds, ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More WordTips (menu)

Formatting Partial Results of a Search

The Find and Replace capabilities of Word are, simply, quite astounding. This is particularly true when using wildcard ...

Discover More

Replacing Multiple Spaces with Tabs

If you get a document or some text that has multiple consecutive spaces used to align information, you'll undoubtedly be ...

Discover More

Matching At the Beginning or End of a Word

The pattern matching capabilities of Word's search engine are quite powerful. You can tailor your search pattern so that ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 4 + 9?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.