将 XML 标记添加到 MS Word 中的斜体文本句子
我遇到了 MS Word 文本格式问题,想知道是否有任何正则表达式极客也使用 MS Word(不太可能,我知道......)
我正在尝试将在 Word 中以斜体显示的句子换行,使用XML 标记,例如
斜体文本
会变成
<i>Text in italics</i>
我可以对单个单词执行此操作,例如,
<i>Text</i> <i>in</i> <i>italics</i>
但我很难弄清楚如何找到一个单词的开头和结尾一组斜体文本,而不是只是个别的话。
到目前为止,我唯一的解决方案是将 MS Word 文档导出为 wML 并执行以下操作:
<w:r w:rsidRPr="00FE6181">
<w:t><hi></w:t>
</w:r>
<w:r w:rsidR="00D555A7" w:rsidRPr="00D77C71">
<w:rPr>
<w:i/>
</w:rPr>
<w:t xml:space="preserve">Text in italics</w:t>
</w:r>
<w:r w:rsidRPr="00FE6181">
<w:t><</w:t>
</w:r>
然后在 word 中重新打开该文档。作为向非技术用户推出的解决方案只是有点复杂。
看起来这应该可以使用 RegExps (或者可能是 VBScript)我只是不知道如何到达那里。
任何帮助表示
感谢
I am up against a MS Word text formatting problem and wondered if there were any Regular Expression geeks who also use MS Word out there (unlikely, I know...)
I am trying to wrap a sentence that appears in italics in Word, using XML markup, e.g.
Text in italics
would become
<i>Text in italics</i>
I can do it for individual words, e.g.
<i>Text</i> <i>in</i> <i>italics</i>
but am having a tough time working out how to find the beginning and the end of a group of italicized text, rather than just individual words.
The only solution i have so far is to export the MS Word doc as wML and do the following:
<w:r w:rsidRPr="00FE6181">
<w:t><hi></w:t>
</w:r>
<w:r w:rsidR="00D555A7" w:rsidRPr="00D77C71">
<w:rPr>
<w:i/>
</w:rPr>
<w:t xml:space="preserve">Text in italics</w:t>
</w:r>
<w:r w:rsidRPr="00FE6181">
<w:t><</w:t>
</w:r>
and then reopen the doc in word. It's just a bit involved to roll out as a solution to a non-technical user.
It looks like this should be possible using RegExps (or maybe VBScript) I just don't know how to get there.
Any help appreciated
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够使用 VBA 宏使用 FIND 对象执行类似的操作。
即
您将要查找的文本指定为 *
,然后将格式指定为斜体。这将找到所有斜体格式的文本。
但是...这是一个问题,如果用户用斜体格式化一个短语,他们+可能+已经格式化了整个短语,或者他们可能已经单独格式化了每个单词,所以你可能“找到”一个短语,但你可能会找到3个每个单词都采用斜体格式。
要解决+那个+问题将是相当困难的。
You should be able to do something like that with a VBA macro, using the FIND object.
ie
You'd specify the text to find as *
and then specify the formatting as italics. that would find all the text that's formatted with italics.
BUT... Here's the rub, if the user formatted a phrase in italics, they +might+ have formatted the whole phrase, or they might have formatted each word seperately, so you might "find" a single phrase, but you might find 3 seperate words each formatted italics.
To work around +that+ problem would be quite difficult.