finding specific sequence of wildcard characters

B

bdr122

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?
 
J

Jay Freedman

bdr122 said:
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
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
K

Klaus Linke

Another trick that's sometimes helpful:

Search two or more asterisks and hide them.
Find what: [\*]{2,}
Replace with: ^& ((+Format>Font>Hidden))

Then set your display to not show hidden text (Tools>Options>View).

Only single asterisks should now be visible, and if you do any Find or
Replace, it'll ignore the hidden asterisks.

When you're done, you can unhide the multiple asterisks again (either with
another Find/Replace, or by selecting everything and unchecking
Format>Font>Hidden).

Regards,
Klaus
 
B

bdr122

Thank you both for your answers. They'll be helpful in the future. In the
mean time, I worked out a solution of my own and I'm including it here in
case anyone else might be able to use it.

What I was specifically looking for was single asterisks followed by one or
two numbers and bounded by brackets. For example: [*4] or [*12], but not
things like [**4] or [***4]. (Anyone who works with legal documents might
recognize these as "star paging" sequences). The search string I eventually
came up with, which worked well, was: \[\*[1-9]{1,2}\]

In the "replace" field, I just used the format "highlighting" and this had
the effect of highlighting the correct instances of "star paging" throughout
the document.

This may be an inelegant solution, but it got the job done.
 
G

grammatim

Isn't "full disclosure" a requirement of any legal process? If you'd
put in the numbers and square brackets in the first place, the
solution would have been a lot simpler.
 

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