Find and Replace with Regex in Microsoft Word 2013

1John5vs7 picture 1John5vs7 · Jun 19, 2014 · Viewed 38.1k times · Source

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.

Answer

hwnd picture hwnd · Jun 19, 2014

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