I am familiar with the use of wild cards from UNIX. I have no problems
finding what I need.
To find MAJOR|v- I put in MAJOR|?- and it finds the stings I need. But when
I try to do a replace with MAJOR|\1x I get an error message. The replace
function gives me the error "The Replace with text contains a group number
which is out of range." I need advice on how to properly use the variable in
the replace that represents the wildcard in the find.
See http://www.gmayor.com/replace_using_wildcards.htm
In this instance you would search for
MAJOR|(?)
replace with
MAJOR|\1x

Signature
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> I am familiar with the use of wild cards from UNIX. I have no problems
> finding what I need.
[quoted text clipped - 5 lines]
> to properly use the variable in the replace that represents the
> wildcard in the find.
>I am familiar with the use of wild cards from UNIX. I have no problems
> finding what I need.
[quoted text clipped - 6 lines]
> in
> the replace that represents the wildcard in the find.
UNIX regex implementations use other wildcards than Word (and other
wildcards than other UNIX regex implementations <g>).
In Word, \1 matches the first "group", that is, the first expression you put
in (brackets).
If you want to find the literal "\1", use \\1 in "Find what".
You get the error message, because there isn't a group \1 in your search.
Regards,
Klaus
Klaus Linke - 05 Oct 2007 06:40 GMT
> If you want to find the literal "\1", use \\1 in "Find what".
Sorry, I noticed (from Graham's reply) you use the backslash in "Replace
with".
I'd have thought \\ would insert a backslash in "Replace with" too, but it
seems it does not.
You could use ^92 though (using the decimal ASCII code of the backslash).
The wildcards \1, \2 ... are used most often in "Replace with", but can
actually be useful in "Find what", too.
Say ([st])?\1 would match "tot" and "sas", but not "sat".
Klaus