Word find/replace equivalent of (word1|word2)

H

Hikari

Hello All,

New poster, I did my best to search for this answer using keywords
such as: atomic grouping, alternatives, bar OR pip equivalent, etc...
but had no luck

My question is, is there/what is the Microsoft Word find/replace
equivalent of the regular expression

(word1|word2)

?

I've obviously tried | and \| with no luck. And any webpage I found
with discussion of advanced find/replace for word did not go into
atomic grouping.

Thanks so much!

-Hikari
 
P

Pesach Shelnitz

Hi Hikari,

If you want to find two different words in a search, you can use wildcards
in the "Find what" box. To do this, perform the following steps.
1. In the "Find what" box, type <[]>{n,m}
2. Between the square brackets, type all the letters that appear in the two
words in alphabetical order.
3. Replace n with the length of the shorter word.
4. Replace m with the length of the longer word.
5. Click "More".
6. Select "Use wildcards".
7. Click "Find Next".

For example, if you want to find "airplane" or "boat", the search string
would be as follows:
<[abeilnoprt]{4,8}>

Unfortunately, this search can also find other words that match the
criteria, but it will find all instances of airplane and boat.

After you do a wildcard search, I recommend that you clear the "Use
wildcards" checkbox and search for something else immediately.

For more information about wildcard searches, see
http://word.mvps.org/FAQs/General/UsingWildcards.htm .
 
G

Graham Mayor

If the words are bracketed as shown then
\([a-zA-Z]{2,}|[a-zA-Z]{2,}\)
will find them
If the words are not bracketed use
<[a-zA-Z]{2,}>|<[a-zA-Z]{2,}>
These will find the whole string. Depending upon what you want to do with
the string having found it determines whether anything else needs to be
added.
See http://www.gmayor.com/replace_using_wildcards.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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