Re: edit-replace function

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Graham Mayor (gmayor_at_DELETECAPSmvps.org)
Date: 02/25/04


Date: Wed, 25 Feb 2004 07:36:04 +0200

Jon seems to have the measure of this - but there are two issues why the
search pattern may not be finding the string
1. There are two spaces between the number and fax - not one as shown in the
original search string (and if you paste the string from your message into
Word, one of those spaces is a non-breaking space. You can check in the
original document by viewing the space characters with CTRL+* a space will
be seen as a dot a non breaking space as a small circle. Change the search
pattern to reflect that.
ie
([0-9\-]{12}) ^s(fax:) - where ^s is the non breaking space.

The search really is quite simple and the details of how to use wildcard
searches can be found in the article in the link that Suzanne posted

Here, you have two round bracketed sections. The brackets are there only to
identify the sections. They are not part of the search itself.
The bit in the first set of square brackets [0-9\-] tells Word to look for
any numeral or hyphen. Because hyphen is a reserved character the \ tells
Word to treat it as a character to search. This Word should look for any
numeral or hyphen. The {12} tells Word to look for a sequence of 12 such
characters. That completes the first section. Next are the spaces and
finally the bracketed fax text. We use the brackets because we want to use
the content in the replace string.

The \2 \1 tells Word to replace with the second bracketed bit followed by a
space then the first bracketed bit.

Adjust the strings to reflect *exactly* what you have and want.

If, as I read somewhere, you want to replace fax: with fx: or vice versa,
you don't need the second bracketed bit. You type exactly what you want in
the replacement eg.

([0-9\-]{12}) fx:
fax: \1

-- 
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
     Graham Mayor -  Word MVP
      Web site www.gmayor.com
  Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Lewis Shanks wrote:
> Jon:
> I'm really feeling stupid here!
>
> The wildcards check box was/is checked per what the "Finding and
> Replacing characters using wildcards" site suggests.
> In the same para which says to check this box, it further says "in a
> macro, set.Find.MatchWildcards = True." If you do not do this, Word
> treats the wildcard characters as if they were ordinary text." I have
> no idea how to do this! I went to Macros and got lost immediately.
>
> Same as before, after making sure that the find box details are
> correctly typed and the replace with box has \2 \1 in it, I again try
> to replace all and end up with no results.
>
> Is there any way that I might be able to call you to discuss further?
>
> Lewis
>
> "Jon Weaver" <anonymous@discussions.microsoft.com> wrote in message
> news:Ob1PY4v%23DHA.4012@tk2msftngp13.phx.gbl...
>> It works exactly as Graham Mayor wrote for the specific pattern you
>> requested.
>>
>> In the Find what box, make sure there is a space before "(fax:)" and
>> that there are no other spaces in the box; also make sure you have
>> used the correct form of bracket -- square [], curly {} and rounded
>> or parentheses ()
>>
>> Also make sure you have clicked More and checked the Use wildcards
>> check box; if this check box is not checked, Word will find and
>> replace nothing
>>
>> Good luck!
>>
>> Jon


Relevant Pages

  • Re: edit-replace function
    ... > original search string (and if you paste the string from your message into ... > original document by viewing the space characters with CTRL+* a space will ... The brackets are there only ... >> Replacing characters using wildcards" site suggests. ...
    (microsoft.public.word.customization.menustoolbars)
  • Re: DataView + RowFilter +Like %
    ... If the string in a LIKE clause contains a * or %, ... characters should be escaped in brackets. ... > we need some escape characters for sql statement ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Grep / Bash problem
    ... When it reads file names from the list that have special characters ... characters like brackets, it apparently attempts to interpret them ... I'd expect grep to output whatever was in $VAR1 at the moment, ... would simply produce the string of characters in $VAR1 as a fixed ...
    (comp.unix.programmer)
  • Wildcards are not allowed in the middle of the String (Dataset Fil
    ... Both the * and % can be used interchangeably for wildcards in a LIKE ... characters should be escaped in brackets. ... Wildcards are not allowed in the middle of a string. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: getline, width
    ... Jon ... >> to display those lines ten characters wide. ... > string s; ...
    (alt.comp.lang.learn.c-cpp)