Please Note: This article is written for users of the following Microsoft Word versions: 2007 and 2010. 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: Formatting Partial Results of a Search.

Formatting Partial Results of a Search

by Allen Wyatt
(last updated November 23, 2015)

4

Agnes has a series of paragraphs that begin with a title that is followed by a period and two spaces. She would like to search for this pattern (multiple words at the beginning of a paragraph followed by a period and two spaces) and underline just the words, exclusive of the period and the spaces.

This can be done with a wildcard search, in the following manner:

  1. If the first paragraph in your document includes information you want to have underlined, position the insertion point at the beginning of the document and press Enter a single time.
  2. Jump to the end of your document. (This is important; the reason will be explained shortly.)
  3. Press Ctrl+H. Word displays the Replace tab of the Find and Replace dialog box.
  4. Click the More button if it is available. (See Figure 1.)
  5. Figure 1. The Replace tab of the Find and Replace dialog box.

  6. Enter the following in the Find What box: ^13[A-z 0-9]{1,}[!. ]
  7. Enter the following in the Replace With box: ^&
  8. With the insertion point in the Replace With box, press Ctrl+U.
  9. Make sure the Use Wildcards check box is selected.
  10. Using the Search drop-down list, chose Up. (You are at the end of the document and you want to search upwards through the document.)
  11. Click on Replace All.
  12. Close the Find and Replace dialog box.
  13. If you pressed Enter in step 1, you can get rid of that blank paragraph.

That's it. The search pattern you entered in step 4 indicates that you want to search for paragraph marks (^13) followed by any length combination of letters and digits ([A-z 0-9]{1,}), terminated by a period and two spaces ([!. ]). The exclamation mark on means that while the period and two spaces are to be used to determine a match, they aren't to be included in the actual text that is found.

All of this is then used in the Replace With, as the ^& combination means to use the "found" text as the replacement. This, however, is formatted with an underline.

Understand that steps 2 and 9 are very important. If you don't do the search from the bottom of the document toward the top, you won't get the desired results.

As presented above, the steps result in all the text before the period being underlined. If you prefer to have a different type of underline (such as underlining only the words), then in step 7 you should click the Format button, choose Font, and use the Underline drop-down list to specify the type of underline you desire.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (9077) applies to Microsoft Word 2007 and 2010. You can find a version of this tip for the older menu interface of Word here: Formatting Partial Results of a Search.

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

Embedding an Excel Chart in a Word Document

Word and Excel usually work pretty well together. This means that you can easily paste charts from Excel into your Word ...

Discover More

Noting Inactivity within a Timeframe

There are many times when you are creating a worksheet that you need to analyze dates within that worksheet. Once such ...

Discover More

Choosing an Insert Method for Pictures

The way that you choose to add pictures to your document can have an effect on the file size of those documents. It is best ...

Discover More

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!

More WordTips (ribbon)

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

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

Searching for Characters

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

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}] 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 6 - 0?

2015-12-12 13:53:54

Phil Rabichow

OK. Problem solved, but with a different solution. It's a 3 step process.
Using wildcards:
1. Find: (^13[A-z 0-9]{1,})([.][ ]{2})
Note that this uses 2 expressions. The first finds a paragraph mark followed by any combination of letters, spaces, & numbers. The 2nd finds a single period followed by 2 spaces.
Replace all: 1%%%% & press Ctrl+U to make it underlined. The 1 replaces only the first expression, so the %%%% (any series of characters that aren't in your document) replaces the period & two spaces, all underlined.
2. Find: %%%%
Replace all: press Ctrl+U to change the formatting to "no underline" & type a period & 2 spaces. (then do replace all)

This technique is the only one I found that changes part of a "find".


2015-12-12 13:41:18

Phil Rabichow

For some reason, this isn't working for me...and it should.

I started by putting in =(rand) for a bunch of paragraphs "The quick brown etc.". In front of some of them, I wrote "This is Title 1, This is Title 2" (no quotes). I followed it with a period & 2 spaces. All the rest of my sentences are separated by 1 space.

If I put in:
^13[A-z 0-9]{1,}[.][ ]{2} OR
^13[A-z 0-9]{1,}[.][ ]{2} OR
it will correctly search up. However, if I put in an exclamation point at the beginning of the last 2 expressions, it finds the beginning of every paragraph. Also, if I change the last expression to [ ], (that's 2 spaces), Word treats it as only 1 space & finds the first sentence in every paragraph.

Any ideas?


2015-06-12 12:55:43

Rick G.

I agree with Sam in that (in Word 2010) the behavior doesn't quite match the description. It is interesting though.

The tip instructions say to search from the bottom up and I wondered why. If I search from the top down, it behaves as Sam indicates, it only underlines strings at the start of a paragraph that do NOT end with a period ("!"="Not"), but do end with some other punctuation, such as a question mark.

If I search from the bottom up as instructed, it does behave differently, but not quite as described in the tip. It underlines strings at the start of a paragraph that end with any punctuation (period, question mark, etc.), and it does not need to be followed by two spaces. So the [!. ] doesn't seem to do anything when searching from the bottom up.


2014-06-26 07:09:01

Sam

Hi!

This is really useful – thanks!

However, from what I can tell, you're not right about this:

"The exclamation mark on means that while the period and two spaces are to be used to determine a match, they aren't to be included in the actual text that is found."

The exclamation mark is an excluder, meaning that you search for anything which isn't what comes after it.

e.g. if you search for [!o] you will search for any character except the letter "o".

However, the function you alluded to here – including something in the search but then not replacing it – is exactly what I want to know how to do!

Any tips for this would be much appreciated!

Thanks

Sam


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.

Newest Tips
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.