Find and Replace with Regex in Microsoft Word 2013

寵の児 提交于 2020-01-21 02:38:11

问题


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.


回答1:


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



回答2:


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


来源:https://stackoverflow.com/questions/24308538/find-and-replace-with-regex-in-microsoft-word-2013

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!