Written by Allen Wyatt (last updated January 20, 2024)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021
In reformatting a document, Leah needs to apply the same paragraph style to all paragraphs beginning with (a), (b), (c), and (d). She can use Find and Replace to apply the style, but then she needs to do a second Find and Replace pass to get rid of the (a), (b), (c), and (d) characters. Leah wonders if there is a way to both apply the style and remove those characters in a single pass.
Actually, this can be accomplished with the use of wildcard characters in Find and Replace. Rather than go through all the steps, just remember that you want to do an advanced search (so that the Find and Replace dialog box is displayed), click the More button (if it is available) and then make sure the Use Wildcard check box is selected. Here is what you want to place in the Find What box:
\([a-d)]\)[ ]{1,}(*^13)
This may look, at first glance, like gibberish—particularly if you are not used to using wildcards—but it is fairly straightforward. The backslashes at the beginning tell Word that the immediately following character should be used as a literal character. That means that the following sequence will search for (a), (b), (c), or (d), any of which would be considered a match:
\([a-d)]\)
If you might have other letters in parentheses, you could change the a-d part to something like a-z, so that any lowercase alphabetic character between parentheses would be matched.
The second part indicates that the next characters should be any number of spaces:
[ ]{1,}
This assumes, of course, that the (a), (b), (c), or (d) is followed by at least one (or more) spaces. If some other character might immediately follow the parenthetical—such as a tab or no spaces at all—then this portion of the search pattern will need to be changed to reflect what is in your document.
The final part of the search pattern is this:
(*^13)
This tells Word to find any number of characters (*) up through and including a hard return. In other words, the entire paragraph is selected. The parentheses around this portion of the pattern are important, as they allow whatever matches this portion of the found text to be referenced in the Replace With field of the Find and Replace dialog box. In fact, this is all that should go into the Replace With field:
\1
This tells Word that you want to replace whatever is found with what is in the first set of parentheses in the Find What pattern, which happens to be the entire paragraph minus the (a), (b), (c), or (d) and any trailing spaces. The only other thing you need to do is make sure that for the Replace With field you pick the style you need applied to replacement. (See Figure 1.)
Figure 1. Setting up the Find and Replace dialog box.
Once the Find and Replace dialog box is set up with the proper patterns (as described above), just click on Replace All and you are done.
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (4274) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
The Find and Replace tool can get rid of trailing spaces in paragraphs quite nicely. If those spaces are at the end of ...
Discover MoreWhen you receive documents created by others, it is not unusual that you'll want to edit what they've written. For ...
Discover MoreWhen using Find and Replace, how Word handles the case of letters in replacements can be confusing. It needn't be, if you ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
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.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments