Searching for whole words using wildcards

J

Johann Swart

I have an alphabetical word list of approximately 160,000 words. Each word is
its own paragraph, i.e. only one word per paragraph.
If I want to search for any word with e.g. five characters only, I write the
following code in the "Find what:" line:
^13([a-z]{5})^13 (the "^13" is for paragraph character)
Using the above code, the search doesn't find anything, yet when I remove
the first "^13", it finds all words of five letters and more with the last
five letters and the paragraph character highlighted.
How should the code be written if one is searching for 5-character words only?
 
P

PamC via OfficeKB.com

Find what: <([a-z]{5})>^13

The < and > are the word delimiters.

PamC


Johann said:
I have an alphabetical word list of approximately 160,000 words. Each word is
its own paragraph, i.e. only one word per paragraph.
If I want to search for any word with e.g. five characters only, I write the
following code in the "Find what:" line:
^13([a-z]{5})^13 (the "^13" is for paragraph character)
Using the above code, the search doesn't find anything, yet when I remove
the first "^13", it finds all words of five letters and more with the last
five letters and the paragraph character highlighted.
How should the code be written if one is searching for 5-character words only?
 
J

Jay Freedman

I'm not sure why that expression isn't finding anything for you; it does work as
expected for me.

However, I think you don't really want both paragraph marks to be selected
anyway. A better search expression would use the characters < and > to signal
the start and end of the word:

<([a-z]{5})>

Look at the list of special characters in
http://www.gmayor.com/replace_using_wildcards.htm for more information.

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

Jay Freedman said:
I'm not sure why that expression isn't finding anything for you;
it does work as expected for me.

May have been a text file with ASCII 10s in it...

Regards,
Klaus
 
J

Jay Freedman

May have been a text file with ASCII 10s in it...

Regards,
Klaus

Yes, there could be odd conversion artifacts, but I took the OP's statement that
it's a Word document to mean that it was created in Word.
 

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