本文介绍了VBA MS-Word:是否可以用通配符替换文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以替换使用通配符找到的文本并将其替换为通配符?例如FindText:="(^13{2}*^13)", Forward:=True, MatchWildcards:=True,,然后将其替换为通配符,例如replacewith:="(^13{2}*^11)".有可能吗?

Is it possible to replace the text that was found using wildcard and replace it with wildcard also? for example FindText:="(^13{2}*^13)", Forward:=True, MatchWildcards:=True, then replace it with wildcard like this replacewith:="(^13{2}*^11)". Is it possible?

推荐答案

注释"中的整个讨论尚不清楚,但是我知道您只需要替换搜索词的一部分,而保留另一部分.是的,可以通过在搜索字词中定义表达式来实现.例如:

The entire discussion in Comments is unclear, but I understand that you need to replace only part of the search term, and retain another part. Yes, that's possible by defining expressions in the search term. For example:

查找:(^ 13 {2} *)^ 13"替换:\ 1 ^ 11

Find: "(^13{2}*)^13"Replace: \1^11

使用括号定义表达式.在查找"文本中可以有多个表达式.引用一个表达式,并让Word在使用反斜杠+索引的替换中使用它,其中index是查找"文本中表达式的编号(位置).在上面的示例中,从您的问题中提取了一个表达式,因此\ 1.

An expression is defined using parentheses. You can have multiple expressions in the "Find" text. Refer to an expression and have Word use it in the replacement using backslash+index, where index is the number (location) of the expression in the Find text. In the above example, taken from your question, there is one expression, so \1.

这篇关于VBA MS-Word:是否可以用通配符替换文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 08:13