word search

Andrea Cova amcova at fastwebnet.it
Tue Mar 2 18:10:44 EST 2004


Hi,
i'm trying to write a program that finds single words that works like this:
i'd like to find a word, the exact word, without making mistakes like, when 
i'm looking for 'cow', he tells me he found it in 'coward'.
I have an idea how to do this in C, but i guess it would be less complicate 
in python.
The findall() function would be ok, but i need to make some modifications 
like this one:
I want the program to find matches only when the word isn't in the middle 
of other letters. Other kinds of chars instead are accepted. (for instance: 
' cow ', '_cow_', '(cow)',' -cow, ' are right matches).


I need this for a program that does the following: i've got a list of song 
titles, saved in a txt file for example, and a list of filenames in a 
directory (mp3 files), and for each song title i want to find the best 
match in the filenames.
Then when all the matches are done I modify the mp3 files' tags according 
to the information in the txt file.
I know there are windows programs to do this, but they don't have functions 
like taking a text list and find the corresponding mp3 on their own.

And two little questions:

1-i read in the manuals that if i want "search()" to ignore the case, i 
have to put the flag I. I can't get this to work. Could you write me an 
example of how to write this? I
2-how can i make also "findall()" be case UNsensitive?

Thank you.





More information about the Python-list mailing list