简体   繁体   English

带有查找通配符的 MS Word VBA 搜索文本

[英]MS Word VBA search text with find wildcards

I need find these matches using "ms word find" with wildcards:我需要使用带有通配符的“ms word find”找到这些匹配项:

{{1,000.00}}
{{-125}} 
{{125-}} 
{{-1’100.00}}  
{{1’100.00-}}  

What should be the Selection.Find.Text for it?它的Selection.Find.Text应该是什么?

I tried this:我试过这个:

[\{]{2}<*>[\}]{2}

but it does not work for some words.但它不适用于某些词。


This wildcard works almost exactly to what I need.这个通配符几乎完全符合我的需要。 I modified a bit to exclude Paragraph return ^13 [\\{]{2}[!\\}][!^13]@[\\}]{2}我修改了一下以排除段落返回 ^13 [\\{]{2}[!\\}][!^13]@[\\}]{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-}} .但是我在匹配这样的段落时遇到问题blabla {{2}} {{-2-}} blabla在这种情况下它匹配整个段落( {{2}} {{-2-}} )然后它匹配{{-2-}}

Can someone tell me the reason, and what I need to change in the wildcards?有人可以告诉我原因,以及我需要在通配符中更改什么吗?

< 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).为了让它们工作,大括号内的第一个和最后一个字符必须是字母或数字(或任何 Word 的Find认为是“单词”字符)。 Try this instead:试试这个:

[\{]{2}[!\}]@[\}]{2}

[!\\}]@ should match one or more of any characters except } . [!\\}]@应该匹配一个或多个除}之外的任何字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM