B
Bob S
I was looking for a pattern to select the innermost matched pair of
curly braces and whatever they contain.
The pattern below, used with wildcards enabled, seemed like it ought
to do it. It should match a pair of left-right braces containing
characters that are not left braces. It works well in simple cases.
\{([!{]@)\}
However, it fails in some cases where there are fields inside the
braces that it ought to find. If you try it on text containing a left
brace, one or more letters, then a field (with field codes displayed),
then a right brace, it fails in an odd way. Not only does it not find
the pattern; the selection may jump to the front of the document or
disappear entirely. If you try it from VBA you will hang Word 2002
SP2.
PS
I eventually realized that maybe the middle brace needs escaping, so I
tried the pattern below, but it fails the same way:
\{([!\{]@)\}
Bob S
curly braces and whatever they contain.
The pattern below, used with wildcards enabled, seemed like it ought
to do it. It should match a pair of left-right braces containing
characters that are not left braces. It works well in simple cases.
\{([!{]@)\}
However, it fails in some cases where there are fields inside the
braces that it ought to find. If you try it on text containing a left
brace, one or more letters, then a field (with field codes displayed),
then a right brace, it fails in an odd way. Not only does it not find
the pattern; the selection may jump to the front of the document or
disappear entirely. If you try it from VBA you will hang Word 2002
SP2.
PS
I eventually realized that maybe the middle brace needs escaping, so I
tried the pattern below, but it fails the same way:
\{([!\{]@)\}
Bob S