I would like to "Find and Replace" entire lines in Microsoft Office Word 2010 which match some criteria.

I tried to find the solution in the official documentation, but I didn't find the answer:

(btw. here are two more useful unofficial documents: Find and Replace using wildcards; Regular Expressions in Microsoft Word)


For example: I would like to search for all the lines which have the "Heading 2" style, and replace them so that they get between ## symbols: so this is the original text: This is my title, and I would like to find it and replace it this way: ## This is my title ## (this way I could transform a text's title into a Wiki-compatible heading 2 without any external plugins (EDIT: sorry, in the meantime I realized the MediaWiki-compatible heading 2 style uses == instead of ##, but it doesn't change the main point)).

So after Ctrl+H, checking "Use wildcards", selecting Format > Style > Heading 2, I've tried this and it did NOT work: (*^13>) or (<*^13>), where ^13 matches "Paragraph break / 'carriage' return" (see this) - this made Word search madly, and the GUI got frozen for minutes (!). At the end, it didn't find anything (but I DO have texts with Heading 2 style).

Microsoft Word 2010 - Find and Replace (*^13>) - Not Responding (Use Wildcards checked)

OK, this is not the appropriate pattern, so what would be the appropriate way to search and replace entire lines in Word?

  • This would be sooooo much easier if Microsoft found out about this new thing called "regex." For that matter, just adding a "start of line" option to their special things list would be a big help. – Carl Witthoft Dec 12 '18 at 12:54

Perhaps I'm missing something, but for some reason I wasn't able to do this in a single search/replace operation:


  1. Before:


  2. Replace empty string (format Heading 2) with "## ^& ##" (no formatting):


  3. After first replace:


  4. Replace "^p ##" (no formatting) with " ##^p" (no formatting) (be aware that there is a space at the beginning of the replace string!):


  5. After second replace:


  • Thanks,this really solves it, with one exception: if I have multiple headers of the same kind after each other, like this: i.imgur.com/tJSFXT2.png; after Find and Replace (sorry, I forgot that in MediaWiki, for parsing headers, I must use == symbols instead of ## symbols, but this doesn't change the main point), Word places == symbols like this: i.imgur.com/aHABiBF.png, and after the 2nd replace, like this: i.imgur.com/HkBGRib.png, which means I have to put an empty line between each of them first!:) – Sk8erPeter Jun 10 '13 at 13:37
  • But I could solve my problem with your solution, so thanks, +1 and accepted! ;) This new line "bug" (?) you mentioned is really strange though. – Sk8erPeter Jun 10 '13 at 13:38
  • 3
    It seems the ^p at the end of the line is part of the text with style Heading 2. So when you attempt to replace Heading Text with ## <Search String> ##, what actually happens is that Heading Text^p is replaced with ## Heading Text^p ##. Thus the trailing ## ends up on the next line preceded with a space. I don't know how to restrict the search string from including the trailing ^p. – Karan Jun 10 '13 at 15:47
  • Yes, this can be the reason, thank you. It would be really good to know how to restrict the search and replace to exclude the newline character. Anyway, you solved it. :) – Sk8erPeter Jun 13 '13 at 12:46

I know the question is old, but not finding any practical solutions here or other places, I thought I'd post the answer for posterity's sake.

Perhaps Word has made enhancements to the function that allowed me to perform a single replace operation that did the job the asker described:

Find What: (*{1,})

---Style: Heading 1

Replace With: \1

---Style: Normal

Note that using (*) instead of (*{1,}) eliminated the first character in the line. Apparently, there's some special meaning involved in (*) that I'm not inclined to research.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.