Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Specifying a Number of Matches.

Specifying a Number of Matches

Written by Allen Wyatt (last updated January 25, 2024)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365


4

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 (9139) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365. You can find a version of this tip for the older menu interface of Word 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

No-border Text Boxes by Default

Text boxes can be a great design element when laying out your documents. If you want those text boxes to have no borders ...

Discover More

Converting a Range of URLs to Hyperlinks

Converting a single URL into a hyperlink is easy. Converting hundreds or thousands can be much harder if you have to rely ...

Discover More

Dragging to Clear Cells

If you want to get rid of the contents of a range of cells, a quick way to do it is with the Fill handle. Yes, you can ...

Discover More

The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!

More WordTips (ribbon)

Searching for Characters

When using pattern matching in a search, you can specify individual characters or ranges of characters you want matched ...

Discover More

Adding an Ellipsis to the Beginning of Some Paragraphs

The Find and Replace feature of Word is very powerful. You can even use it to add a unique character to the beginning of ...

Discover More

Replacing Two Tabs with a Space in Limited Situations

The Find and Replace feature of Word is very powerful, allowing you to finely target exactly what you want to search. ...

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 six minus 4?

2019-08-29 03:41:04

Zvi

This is not a peculiarity.
If you have a 3 digit number ending in 7, it meets the rules of [0-9]{2,3}, since it is a 3 digit number.
There is no 7 after the 3 digit number.
So the 3 digit number does NOT meet the search criterion.


2015-04-22 06:19:53

Richard

I think Ken means [0-9]{2,3}7.


2015-03-21 05:48:19

Ken Endacott

Here is a peculiarity in using curly braces.

Supposing you want to find any two or three numeric digits followed by the letter a. The search specification [0-9]{2,3}a will find 12a and 123a and so on.

One would think that a similar specification could be used to find three or four digit numbers that end in 7. Try [0-9]{2,3)7. Not so! It will only find four digit numbers ending in 7.


2015-03-21 05:44:25

Ken Endacott

Here is a peculiarity in using curly braces.

Supposing you want to find any two or three numeric digits followed by the letter a. The search specification [0-9]{2,3}a will find 12a and 123a and so on.

One would think that a similar specification could be used to find three or four digit numbers that end in 7. So try [0-9]{2,3)7. Not so! It will only find four digit numbers ending in 7.


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu 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.