MS Word VBA search text with find wildcards

百般思念 提交于 2019-12-25 03:28:36

问题


I need find these matches using "ms word find" with wildcards:

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

What should be the Selection.Find.Text for it?

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}

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?


回答1:


< 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 }.



来源:https://stackoverflow.com/questions/7408485/ms-word-vba-search-text-with-find-wildcards

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!