带有查找通配符的 MS Word VBA 搜索文本 [英] MS Word VBA search text with find wildcards
问题描述
我需要使用带有通配符的ms word find"找到这些匹配项:
I need find these matches using "ms word find" with wildcards:
{{1,000.00}}
{{-125}}
{{125-}}
{{-1’100.00}}
{{1’100.00-}}
它的 Selection.Find.Text 应该是什么?
我试过了:
[\{]{2}<*>[\}]{2}
但它对某些词不起作用.
but it does not work for some words.
这个通配符几乎完全符合我的需要.我修改了一下以排除段落返回 ^13 [\{]{2}[!\}][!^13]@[\}]{2}
This wildcard works almost exactly to what I need. I modified a bit to exclude Paragraph return ^13 [\{]{2}[!\}][!^13]@[\}]{2}
但是我在匹配这样的段落时遇到问题 blabla {{2}} {{-2-}} blabla
在这种情况下它匹配整个段落 ({{2}} {{-2-}}
) 然后匹配{{-2-}}
.
However I have a problem matching a paragraph like this blabla {{2}} {{-2-}} blabla
in this case it matches the whole paragraph ({{2}} {{-2-}}
) and then it matches {{-2-}}
.
谁能告诉我原因,以及我需要在通配符中更改什么?
Can someone tell me the reason, and what I need to change in the wildcards?
推荐答案
<
和 >
是 word-boundary 通配符.为了让它们工作,大括号内的第一个和最后一个字符必须是字母或数字(或任何 Word 的 Find
认为是单词"字符).试试这个:
<
and >
are the word-boundary wildcards. For them to work, the first and last characters inside the braces would have to be letters or digits (or whatever Word's Find
considers to be a "word" character). Try this instead:
[\{]{2}[!\}]@[\}]{2}
[!\}]@
应该匹配一个或多个除了 }
之外的任何字符.
[!\}]@
should match one or more of any characters except }
.
这篇关于带有查找通配符的 MS Word VBA 搜索文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!