another "Find" bug

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
 
J

Jezebel

The curly braces that mark the start and end of fields are not the same as
curly braces entered from the keyboard, and you can't find them by matching
against curly brace characters, escaped or not. So your Find string
shouldn't be finding the field code braces anyway. But that doesn't explain
why it's causing grief, either.

(You can search for fields using ^d, but that doesn't work with wildcards.)
 
P

Pat Garard

G'Day Bob,

Are you by any chance a user of Star Office or
Open Office (or just an experienced Unix/Linux user)?

The kind of pattern represented by 'regular expressions'
in that environment is NOT generally supported in the
Windows environment and specifically not in Word.

There is no equivalent of the 'literal' (escape) character.

If you are not aware of Star/Open Office, please see:
http://www.openoffice.org/, and you will find a FREE
download available of OpenOffice.org v1.1.2 - a full
featured office suite comprising:
Writer - Word Processor
Calc - Spreadsheet
Impress - Presentation and
Draw - Drawing.

These products are directly related to Sun StarOffice, have a
surprising degree of compatibility with MS Office, and do
seem to be stable (they comprise the portions of StarOffice
directly owned by Sun Microsystems).

Writer DOES have the 'pattern' Find facility you require.

If you stick to a feature-set that is common to Word and Writer,
then you can open and save .doc format files in either program.

I hope this helps.

--
Regards,
Pat Garard
Australia

______________________________________
 
J

Jezebel

The kind of pattern represented by 'regular expressions'
in that environment is NOT generally supported in the
Windows environment and specifically not in Word.

Actually it is, Pat. Word's Find method, with wildcards enabled, supports
exactly that kind of regular expression.
There is no equivalent of the 'literal' (escape) character.

You can enter literals as \nnn, or backslash the characters that otherwise
have special meaning for wildcard searching.
 
P

Pat Garard

Touché (AGAIN) Jezebel,

....and I never knew! Any idea what version that came in?
--
Regards,
Pat Garard
Australia

______________________________________
PS Instead of cleaning cleaning Bush's
Pet Goat's nose - you should try
doing some Training.
 
H

Helmut Weber

Hi Pat,
...and I never knew! Any idea what version that came in?
Word 97, I guess.
Have a look at:
http://word.mvps.org/faqs/General/UsingWildcards.htm
But AFAIK there are some differences compared to a unix system,
as e.g. searching for 0 or more occurences of a character is not
possible, and @, which should stand for 1 or more occurences of a
character, does not always return the expected result:
Square brackets are used to indicate the selection after executing.
Search for lo@?
Given: lo , loo , looo ,
Result: [lo ] [loo] [loo]o
Search for lo@,
Given: lo, loo, looo,
Result: [lo,] [loo,] [looo,]
 
S

Suzanne S. Barnhill

The concept of regular expressions was, I think, introduced in Word 6.0. The
word "wildcards" was not used. The control button was labeled "Use Pattern
Matching," and the wildcards were called "advanced search operators," but
they appear identical to today's wildcards.



Helmut Weber said:
Hi Pat,
...and I never knew! Any idea what version that came in?
Word 97, I guess.
Have a look at:
http://word.mvps.org/faqs/General/UsingWildcards.htm
But AFAIK there are some differences compared to a unix system,
as e.g. searching for 0 or more occurences of a character is not
possible, and @, which should stand for 1 or more occurences of a
character, does not always return the expected result:
Square brackets are used to indicate the selection after executing.
Search for lo@?
Given: lo , loo , looo ,
Result: [lo ] [loo] [loo]o
Search for lo@,
Given: lo, loo, looo,
Result: [lo,] [loo,] [looo,]
---
Word's wildcard search is a mighty tool, but not too reliable.
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
 
P

Pat Garard

G'Day Helmut,

Thank you the information.

And greetings also to Bavaria!
===
Guten Tag Helmut,

Danke für die Informationen.

Und Grüße auch nach Bayern!
--
Regards,
Pat Garard
Australia

______________________________________
 
P

Pat Garard

G'Day Suzanne,

.....and for all these years........!
--
Regards,
Pat Garard
Australia

______________________________________
 
J

Jezebel

Helmut's right about the limitations. The big difference between Word's
regular expressions and those of (say) Unix is that Word uses minimal
matching -- finding the smallest possible string that matches your
pattern -- while Unix et all use maximal matching.

So a search for [not paragraph mark] will find an entire paragraph in Unix
(the maximal sequence that does not include a paragraph mark); but finds
only the a single character in Word.
 
B

Bob S

Yes, I know they braces are different; it is supposed to find the
innermost real braces, which in this test happen to be the outermost
characters of the line.

I guess I will have to do two separate find operations...

Bob S


The curly braces that mark the start and end of fields are not the same as
curly braces entered from the keyboard, and you can't find them by matching
against curly brace characters, escaped or not. So your Find string
shouldn't be finding the field code braces anyway. But that doesn't explain
why it's causing grief, either.

(You can search for fields using ^d, but that doesn't work with wildcards.)



Bob S said:
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
 
K

Klaus Linke

Hi Bob,

It is a bug ... or at least a severe limitation in wildcard searches.
Any field will stop the current match, no matter if it displays any text,
or whether you have field codes displayed or not.
And you can't find fields themselves at all in a wildcard search, neither
with ^d nor with the codes of the field braces ^19 and ^21.

Hidden text is problematic, too. While it's ignored in a normal
Find/Replace when it doesn't display, it'll still mess up wildcard
searches.
Say you type "abc" and hide the "b".
Neither "ac" nor "abc", not even "a?" will match in a wildcard search.

Maybe something for http://register.microsoft.com/mswish/suggestion.asp ...
Would be nice if (only) text as it currently displays would be searched,
and if fields could be manipulated with a wildcard replace.

Regards,
Klaus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top