MS Word VBA search text with find wildcards
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 i开发者_开发知识库t?
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?
<
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 }
.
精彩评论