Re: finding specific sequence of wildcard characters



bdr122 wrote:
I'm using Word 2007 on Vista Business. In a word document, I'd like
to find single instances of the "*" character (i.e., the asterisk
character). The document contains several single "*" characters as
well as double "**" and triple "***" sequences (each of these
asterisk sequences is also followed by a different sequence of
numbers). But I only want to find the singles, not the doubles or
triples. I've tried the following three searches with wildcards on:
\*{1}
[\*]{1}
(\*){1}
In each case, word finds every "*" character, including those
contained in doubles or triples. Does anyone know of a way to just
find instances of the single "*" character?

Put yourself in the place of the little man inside the computer who has to
carry out your instructions. Scanning through the document, he sees an
asterisk character and highlights it. Then he moves one character to the
right, and there's another asterisk, so he highlights that one -- you
haven't told him not to. One more character to the right, "Oh, look, there's
another one!" And so it goes.

To limit the matches to single asterisks, you have to be very literal and
give the instruction "find one asterisk where the character to its left is
not an asterisk, and the character to its right is not an asterisk". In
wildcard syntax,

[!\*][\*][!\*]

Of course, this is going to highlight all three characters. If you're doing
only a find, there's not much harm in that. If you're doing a replacement,
though, and you want to do something with the asterisk, you need to modify
the search expression to put parentheses around each bracketed term

([!\*])([\*])([!\*])

and use a replace expression like

\1something\3

so the preceding and following characters don't change. Or you may need to
program a macro to do only a find, and then do some more complicated
processing of the matched characters -- for example, if you want to change
the formatting of the asterisk but not of the surrounding characters.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.


.



Relevant Pages

  • RE: String Manipulation
    ... escaped asterisk. ... The slash is still special because it's the regexp ... The square brackets are a character class. ...
    (perl.beginners)
  • Re: Message ID with mySQL?
    ... > conventions change. ... Hence the asterisk (or some other character that will do the job). ...
    (alt.html)
  • Re: Bash: Asterisk reading problem
    ... Pan wrote: ... character from a set of data files. ... the asterisk symbol, which is causing problems with the exporting process. ...
    (uk.comp.os.linux)
  • Re: Not like query
    ... To exclude anything beginning with 3 asterisks: ... However, asterisk is not a special character in the first case, so it ... >Can anyone suggest the correct syntax for this criteria. ...
    (microsoft.public.access.queries)
  • Re: writestring error, what does it usually mean
    ... Post replies and follow-ups, don't e-mail them. ... Two reasons actually. ... I was initially puzzled with the '$' character. ... anywhere that this was needed to dereference a variable before, ...
    (comp.lang.postscript)