The Problem:
Find and Replace isn’t flexible enough! I need to check references to a bunch of different product codes, CP408 through CQ917. As you can imagine, searching for «C» with «Match case» on finds me every capital C in the document. I want a better way!
The Solution:
There are two ways you can do this. The easiest way is to search for c^$^#^#^#
, which finds a C followed by any single letter and then three digits. To find special items, use the codes explained in Table 3-1. You can enter them by clicking the Special button in the Find and Replace dialog box (see Figure 3-12) when the «Use wildcards» box is unchecked, but once you find how useful they are, you’ll find it quicker to type them.
Table 3-1. Special codes for Find and Replace
Code |
Meaning |
---|---|
|
A paragraph mark. |
|
A tab. |
|
Any single character (letter or number). For example, |
|
Any digit. For example, |
|
Any single letter (not a digit). |
|
A caret (the single caret is used to identify other codes). |
|
A section character (�). |
|
A paragraph character (-not a paragraph mark). |
|
A column break. |
|
An em dash (). |
|
An en dash (). |
|
An endnote mark. |
|
A field. |
|
A footnote mark. |
|
A graphic. |
|
A manual line break. |
|
A manual page break. |
|
A nonbreaking hyphen. |
|
An optional hyphen. |
|
A nonbreaking space. |
|
A section break. |
|
Whitespace (one or more spaces, one or more tabs, or a combination of the two). |
Figure 3-12. The Special pop-up menu in the Find and Replace dialog box provides an easy way to enter the codes for special items.
The other way is to use regular expressions
, or combinations of text and wildcards. Check the «Use wildcards» box and enter C[P-Q]
(in capitals, as it’s case-sensitive) in the «Find what» box, then click the Find Next button.
by updated Aug 01, 2016
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 Special Characters.
Written by Allen Wyatt (last updated September 1, 2018)
This tip applies to Word 97, 2000, 2002, and 2003
Word allows you to search not just for text, but also for special characters that normally do not print. If you are working with documents that use tabular material, you will find yourself searching for tab characters quite a bit. To search for tabs, follow these steps:
- Press Ctrl+F. Word displays the Find tab of the Find and Replace dialog box.
- Click the More button, if it is available. (See Figure 1.)
- In the Find What box, enter the text for which you want to search. For example, to search for a tab character enter ^t (it is important to use a lowercase t). Alternatively, you can click on the Special button and select a special character from the list.
- Set other searching parameters, as desired.
- Click on Find Next.
Figure 1. The Find tab of the Find and Replace dialog box.
Often, you will be searching for other special characters such as breaks and paragraph marks. It can be faster to remember these and type them in rather then looking them up all of the time. The following is a list of the more common special characters:
Special Character | Symbol | |
---|---|---|
Paragraph Marker | ^p | |
Manual Page Break | ^m | |
Section Break | ^b | |
Column Break | ^n | |
Em Dash | ^+ | |
En Dash | ^= | |
Graphic | ^g | |
Any Character | ^? | |
Any Digit | ^# | |
Any Letter | ^$ | |
White Space | ^w | |
Caret Character | ^^ |
You can also use many of these same special characters in the Replace With box when doing a search and replace operation. You cannot, however, use the special white space character (^w) in the Replace With box.
In addition, Word allows you to search for any character as long as you know its ASCII value. (You can find ASCII values for characters in the back of many programming books.) All you need to do is use the caret, followed by a zero and then the three-digit value of the character. For instance, if you wanted to search for a capital A, whose ASCII value is 65, you would use ^0065 as your search string.
WordTips is your source for cost-effective Microsoft Word training.
(Microsoft Word is the most popular word processing software in the world.)
This tip (10) 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 Special Characters.
Author Bio
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. Learn more about Allen…
MORE FROM ALLEN
Resizing Your Table
Need to make your table a different size? It’s easy to do, using the same general technique you use when resizing a …
Discover More
Conditionally Playing an Audio File
You can add audio files to an Excel worksheet, but what if you want a particular audio file to play only when a value in …
Discover More
Automatically Adding Tabs in Footnotes
When you add a footnote to a document, Word’s normal formatting adds a space after the footnote number and before the …
Discover More
More WordTips (menu)
Searching for Special Hyphens
Word allows you to use a couple of different types of hyphens in your document, each with a different purpose. If you …
Discover More
Quick and Dirty Paragraph Count
Need to know how many paragraphs are in a document? You can use Word’s Find and Replace feature to get a count quickly.
Discover More
Special Characters in Pattern Matching
The most powerful search engine in Word use pattern matching, but the way you specify special characters in a …
Discover More
In addition to simply searching for a specified word or phrase, you can use Word’s advanced search features to search using wildcards or search for special characters.
Search with Wildcards
A “wildcard” is a character (or a short string of characters) that represents multiple characters in a search.
- Click the Find list arrow.
- Select Advanced Find.
- Click the More button.
- Click the Use wildcards check box.
If you’re familiar with wildcards, you can type them out as part of the search phrase. You can also insert them from a menu.
- (Optional) Click the Special menu to select a wildcard.
The wildcard syntax is shown at the top of the list. The syntax can get tricky, and wildcards can be tough to understand without examples. The table on the next page should help explain some common examples.
- Enter a search phrase in the Find what text field.
- Click Find Next.
The search is conducted. Make sure to be careful if you’re using wildcard searches to find and replace text. Keep an eye on the results in case something unexpected is found.
Some common wildcards are shown in the following table.
Wildcard | Purpose | Example |
---|---|---|
? | Any single character | h?t will find hat, hot, and h t |
* | Any number of characters | a*d will find ad, ahead, and as compared |
[ ] | One of these characters | t[ai]n will find tan and tin, but not ton |
[ — ] | One of these characters in a range | [b-d]ot will find bot, cot, and dot |
[! ] | Not the specific characters | [!d]ust will find rust and must, but not dust |
< | The beginning of a word | <(some) will find something, someone, and somewhere |
> | The end of a word | (one)> will find stone, cone, and provolone |
@ | One or more instances of a character | cor@al will find coral and corral |
{n} | Exactly n instances of a character | ^p{2} will find two consecutive paragraph breaks |
{n,} | At least n instances of a character | 10{2,} will find 100, 1000, and 10000 |
{n,m} | Between n and m instances of a character | 10{2,3} will find only 100 and 1000, not 10000 |
Search for Special Characters
You can also specifically search for special characters, such as line and page breaks, paragraph marks, fields, graphics, and dashes.
- Click the Find list arrow.
- Select Advanced Find.
- Click the More button to expand the dialog box, if necessary.
If you’ve expanded the Find and Replace dialog box in a recent search, without collapsing it back down, it will open in an expanded state.
- Click in the Find what text field.
- Click the Special button.
The Special menu lists the special formatting characters that can be searched for.
- Select a special character.
When you select a special character from the menu, the text code for that special character is inserted.
- Click the Find Next button.
The next instance of the selected special character is found.
You can find and replace one special character with another (to replace section breaks with page breaks, for example) on the Replace tab of the Find and Replace dialog box.
FREE Quick Reference
Click to Download
Free to distribute with our compliments; we hope you will consider our paid training.
Find and Replace Text and Numbers in Word
by Avantix Learning Team | Updated March 7, 2022
Applies to: Microsoft® Word® 2013, 2016, 2019, 2021 or 365 (Windows)
You can find and replace in Word using the Find and Replace dialog box as well as the Navigation Pane. If you use the dialog box, you can find and replace text and numbers and use wildcards for more advanced find and replace tasks. Wildcards are useful when you are not able to find an exact match. You can display the Find and Replace dialog box using a keyboard shortcut or the Home tab in the Ribbon.
Recommended article: How to Quickly Remove Hard Returns in Word Documents
Do you want to learn more about Microsoft Word? Check out our virtual classroom or in-person Word courses >
Note: Screenshots in this article are from Word 365 but are similar in previous versions of Word.
The Replace command appears on the Home tab in the Ribbon in the Editing group:
Using the Find and Replace dialog box to replace words or characters (and match case)
You can perform simple find and replace tasks using the Replace dialog box in its collapsed state. To access more advanced options, you will need to click More in the Replace dialog box to expand it.
To use the Find and Replace dialog box to find and replace text in Word (words or characters) and match case if needed:
- Click the Home tab in the Ribbon.
- In the Editing group, click Replace to display the Replace dialog box. Alternatively, press Ctrl + H if you prefer to use a keyboard shortcut to open the Replace dialog box.
- Enter the text you want to find in the Find What box. You can specify whether Word should locate only matches with the exact capitalization by clicking More and then selecting or checking Match case.
- Enter the text you want to replace in the Replace box.
- Click Find Next and then click Replace for each occurrence or click Replace All.
- Click Close.
In the following example, the Replace dialog box has been expanded to display other options including Match case:
Finding and replacing using wildcards
To use wildcards, you will need to use the Find and Replace dialog box and expand it to display more options. You can then select the option to Use wildcards. A wildcard can replace one or more characters in a string of text or numbers. The most common wildcard is the asterisk (*).
It’s important to note that wildcard searches are case sensitive. Also, Word uses «lazy» pattern matching so it will stop matching as soon as possible. This means that you could enter part of a word and find that part without using wildcards.
To find and replace text using wildcards in Word:
- Position the cursor at the location in the document where you want to start finding and replacing. If you want to start at the beginning of the document, you can press Ctrl + Home.
- Click the Home tab in the Ribbon.
- In the Editing group, click Replace. Alternatively, press Ctrl + H. A dialog box appears.
- Select More to expand the dialog box.
- Click in the Find What box.
- Select or check the Use wildcards checkbox.
- Enter the text and wildcard(s) you want to use. For example, enter s*l to find any text starting with s and ending with l.
- Click in the Replace with box.
- Enter the text you want to use to replace the text in the Find what box.
- Click Find Next to find the first instance of the characters you want to find.
- Click Replace or Replace All. If you click Replace, Word will select the next matching characters in the Find what box. If you click Replace All, Word will display a dialog box with the number of replacements. In this case, click OK.
- If necessary, click Replace again. Repeat for each instance.
- Click Close to close the dialog box.
In the following example, b*s has been entered in the Find what box to find any word starting with starting with b and ending with s:
If you want to undo a Replace or Replace All action, close the dialog box and press Ctrl + Z.
Using common wildcards
The most common wildcards you can use in the Find and Replace dialog box are the asterisk (*) to find multiple characters and the question mark (?) to find a single character.
For example:
b*l will find ball and barrel (a character followed any characters and ending with a specific character)
h?ll will find hill and hall (a character followed by any single character and then followed by 2 characters)
Using wildcards to find one or more instances of the same character
You can also use @ as a wildcard to find one or more instances of the same character.
For example:
catchal@ will find catchal or catchall
Using wildcards for alternate characters and ranges
You can also use wildcards to find alternate characters or ranges of characters. These are entered in square brackets [ ] and may be combined with other wildcards.
[ ] can be used to find each of a set of characters
[ – ] can be used to find each of a set of characters in a range
You can use any character or series of characters in a range within the square brackets (including the space character). Characters are processed in alphanumeric order from lowest to highest.
For example:
[abc] will find any of the letters a, b, or c
[G] will find the upper case letter G
[A-Z] will find any upper case letter
[0-9] will find any single number
[13579] will find any odd number
[0-9A-z] will find any number or letter
f[ai]n will find each of the characters in square brackets such as fan or fin
[b-f]at will find each of a range of characters such as bat, cat, and fat
Using wildcards to omit characters
If you want to omit specific characters, you can use an exclamation mark (!) combined with square brackets.
For example:
[!f]ast will find last and past but not fast
Using wildcards to find the beginning or end of a word
You can use the less than symbol (<) to find the beginning of a word and the greater than symbol (>) to find the end of a word. These wildcards are combined with characters in round brackets or parentheses.
For example,
<(watch) will find watching or watchman
(all)> will find wall or stall
These wildcards can be problematic if you are using a wildcard and you want to find > or < as characters in the document. If this is the case, enter a backslash () in front of the character so that it is not treated as a wildcard.
For example,
<*> will find <h1> or <h2>
Using wildcards to find instances of a character
You can use curly brackets { } to specify the number of instances of a character. These brackets can be combined with a comma to specify the number of instances. Counting can be used with individual characters or with sets of characters.
{n} is used to find the number of instances of a character
{n,} is used to find at least n instances of a character
{n,m} is used to find between n and m instances of a character
For example:
^p{2} will find two consecutive paragraph marks or hard returns (^p is a special character for a paragraph mark in Word)
{3} will find three spaces (there is a space entered before the first curly bracket)
30{2,} will find at least 2 instances of the preceding character such as 3000 or 30000
30{3,4} will find between 3 and 4 instances of the preceding character such as 30000 or 300000 not 300
These last wildcards are particularly useful if you are finding and replacing numbers in Word.
The Find and Replace dialog box offers more functionality as well. For example, you can also Find and Replace Formatting in Word.
Subscribe to get more articles like this one
Did you find this article helpful? If you would like to receive new articles, join our email list.
More resources
How to Add Page Numbers in Word (Step by Step)
How to View Document Statistics in Microsoft Word
How to Update All Figure Numbers in Microsoft Word
How to Check Word Count in Microsoft Word (4 Ways)
How to Superscript or Subscript in Word (with Shortcuts)
Related courses
Microsoft Word: Intermediate / Advanced
Microsoft Word: Designing Dynamic Word Documents Using Fields
Microsoft Word: Long Documents Master Class
Microsoft Word: Accessible Word Documents
Microsoft Excel: Intermediate / Advanced
Microsoft PowerPoint: Intermediate / Advanced
VIEW MORE COURSES >
Our instructor-led courses are delivered in virtual classroom format or at our downtown Toronto location at 18 King Street East, Suite 1400, Toronto, Ontario, Canada (some in-person classroom courses may also be delivered at an alternate downtown Toronto location). Contact us at info@avantixlearning.ca if you’d like to arrange custom instructor-led virtual classroom or onsite training on a date that’s convenient for you.
Copyright 2023 Avantix® Learning
Microsoft, the Microsoft logo, Microsoft Office and related Microsoft applications and logos are registered trademarks of Microsoft Corporation in Canada, US and other countries. All other trademarks are the property of the registered owners.
Avantix Learning |18 King Street East, Suite 1400, Toronto, Ontario, Canada M5C 1C4 | Contact us at info@avantixlearning.ca
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.