Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find and Replace with Regex in Microsoft Word 2013

Tags:

I am editing an e-book document with a lot of unnecessary markup. I have a number of sections in the text with code similar to this:

<i>Some text here</i> 

I am trying to run a regex find and replace that will find any phrase between the two i-tags, remove the i-tags, and apply a style to the text.

Here is what I'm using to search:

Find: (<i>)(*)(</i>) Replace: \2 

I'm also selecting Styles > i (for italic). This tells our conversion software to apply italics to the text. If I leave the i-tags, what ends up happening is ScribeNet's conversion process converts them to hex-values so that they show up as literal text in the e-book. Messy.

When I run this search, I get no results. I have "use wildcards" checked. What am I missing? According to Microsoft's help website, * is used to represent any number or type of characters, and individual strings are supposed to be enclosed in parentheses.

like image 751
1John5vs7 Avatar asked Jun 19 '14 14:06

1John5vs7


People also ask

How do you find and replace in word 2013?

Find and replace basic text , type the word or phrase that you want to find, and Word will highlight all instances of the word or phrase throughout the document. To replace found text: Select the magnifying glass, and then select Replace. In the Replace With box, type the replacement text.


2 Answers

To search for a character that's defined as a wildcard, place a backslash (\) before that character. The * itself matches any string of characters, so use the range quantifier to match (1 or more times)

Find: \<i\>(*{1,})\</i\> Replace: \1 
like image 146
hwnd Avatar answered Oct 20 '22 20:10

hwnd


Search for \<i\>(*{1,})\</i\> and replace with \1. Don't forget to check Use wildcard.

There is a reference table for Word's "regular expressions" here: http://office.microsoft.com/en-ca/word-help/find-and-replace-text-by-using-regular-expressions-advanced-HA102350661.aspx

  • < and > are special characters that need to be escaped
  • * means any character
  • {1,} means one or more times
like image 25
dee-see Avatar answered Oct 20 '22 20:10

dee-see