本文介绍了在Microsoft Word 2013中查找并替换为正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编辑带有很多不必要标记的电子书文档.我在文本中有很多部分,其代码与此类似:

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-tag之间的任何短语,删除i-tag,并对文本应用样式.

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"(斜体字).这告诉我们的转换软件对文本应用斜体.如果我离开了i-tag,最终会发生的是ScribeNet的转换过程将它们转换为十六进制值,以便它们在电子书中显示为原义文本.凌乱的.

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.

运行此搜索时,没有任何结果.我已选中使用通配符".我想念什么?根据Microsoft的帮助网站,*用于表示任意数量或类型的字符,并且单个字符串应该用括号括起来.

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

这篇关于在Microsoft Word 2013中查找并替换为正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 07:06