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: Specifying a Number of Matches.

Specifying a Number of Matches

Written by Allen Wyatt (last updated June 18, 2016)
This tip applies to Word 97, 2000, 2002, and 2003


Word allows you to use pattern matching when searching for information in a document. Pattern matching is enabled by making sure the Use Wildcards check box is selected in the Find and Replace dialog box.

One of the things that pattern matching allows you to do is to specify how many of the preceding character you want to find. You make this specification by enclosing a number within curly braces. For instance, you already know that if you want to search for any single digit, you specify this as [0-9]. If you want to search for any three digits, you can do it either as [0-9][0-9][0-9] (which is rather awkward), or you can simply use [0-9]{3}.

You can also specify a range of matches to be made. If you are looking for any three-, four-, or five-digit sequences, you can do so by searching for [0-9]{3,5}. Remember, however, that the value or range specified in the curly braces only applies to the previous character being searched for.

If you leave off the last number in the curly braces, you are not setting an upper limit. For instances, let's say you wanted to search your document for any periods followed by two or more spaces. You could do this by entering a period followed by a space followed by {2,}. Likewise you could search for a sequence of two or more tabs by using the specification ^t{2,}.

Pattern matching in Word does allow for one shortcut to specifying a quantity. Let's say you want to search for any number of semicolons in your document. You can do so by using a specification of ;{1,}, but you can also use the specification ;@. The at sign is functionally the same as {1,}.

It is interesting to note that you can use the quantity specifier with wildcards, but probably not with the desired results. For instance, if you wanted to search for the letters t and d separated by two characters, you can use the search specification of t??d. But if you use t?{2}d as your specification (which you would think would be the same), it is instead translated by Word as t*d, which is definitely not what you would want. Using a quantity specification with the asterisk wildcard has no effect.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (1661) 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: Specifying a Number of Matches.

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

Saving Document Versions

Documents often go through several versions during development. For this reason, Word provides a feature that allows you ...

Discover More

Status Bar Summing No Longer Available

When you select a range of cells, Excel normally displays the sum of those selected cells on the status bar. If the sum ...

Discover More

Word 2016 Indexes and Special Tables (Table of Contents)

One of the finishing touches used in some types of documents are an index or a special table, such as a table of ...

Discover More

Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!

More WordTips (menu)

A Fast Find-Next

Want a quick, easy way to "search again" for the next occurrence of what you need? Use the technique in this tip and ...

Discover More

Using Search Text in the Replacement

When you use the Find and Replace tool in Word, you may want to include what you searched for in the replacement text. ...

Discover More

Initiating a New Search

I do a lot of searching in my documents. Sometimes the searches may not go exactly as I expected. Here are some things I ...

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 two more than 7?

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.