searching for matches within a word list

Rajarshi Guha rajarshi at presidency.com
Tue Jul 29 17:35:58 EDT 2003


Hi,
  I have a large list of words (each on its own line) 
and I would like to find words that contain a specific string.

I have been trying to use a regexp but I cant see how I can find the
word that contained the regex pattern - all I get is the pattern itself
if I use match or findall.

I know that I could just go through the list line by line and see if the
regex matches or not - but that method seems horifically inefficient.

Does anybody have any suggestions as to how I could solve this
efficiently?

Thanks,
Rajarshi




More information about the Python-list mailing list