On 25/04/2006 8:51 PM, Iain King wrote: > John Machin wrote: >> On 25/04/2006 6:26 PM, Iain King wrote: >>> hawkesed wrote: >>>> If I have a list, say of names. And I want to count all the people >>>> named, say, Susie, but I don't care exactly how they spell it (ie, >>>> Susy, Susi, Susie all work.) how would I do this? Set up a regular >>>> expression inside the count? Is there a wildcard variable I can use? >>>> Here is the code for the non-fuzzy way: >>>> lstNames.count("Susie") >>>> Any ideas? Is this something you wouldn't expect count to do? >>>> Thanks y'all from a newbie. > > snip > >>> steven = re.compile("Ste(v|ph|f)(e|a)n") >> What about Steffan, Etienne, Esteban, István, ... ? >> > > well, obviously these could be included: > "(Ste(v|ph|f)(e|a)n|Steffan|Etienne|Esteban)", but the OP never said he > wanted to translate anything into another language.
Neither did I. But if you have to cope with a practical situation like where the birth certificate says István and the job application says Steven and the foreman calls him Steve, you won't be stuffing about with hand-crafted REs, one per popular given name. Could be worse: the punter could have looked up a dictionary and changed his surname from Kovács to Smith; believe me -- it happens. Oh and if you cast your net as wide as the Pacific islands, chuck in Sitiveni. That's enough examples. We won't go near Benjamin :-) -- http://mail.python.org/mailman/listinfo/python-list