Counting elements in a list wildcard

Iain King iainking at gmail.com
Wed Apr 26 05:57:10 EDT 2006


Edward Elliott wrote:
> John Machin wrote:
> > On 25/04/2006 6:26 PM, Iain King wrote:
> >> iain = re.compile("(Ia(i)?n|Eoin)")
> >> steven = re.compile("Ste(v|ph|f)(e|a)n")
> >
> > IMHO, the amount of hand-crafting that goes into a *general-purpose*
> > phonetic matching algorithm is already bordering on overkill. Your
> > method using REs would not appear to scale well at all.
>
> Also compare the readability of regular expressions in this case to a simple
> list:
> ["Steven", "Stephen", "Stefan", "Stephan", ...]

Somehow I'm the advocate for REs here, which: erg. But you have some
mighty convenient elipses there...
compare:

steven = re.compile("Ste(v|ph|f|ff)(e|a)n")
steven = ["Steven", "Stephen", "Stefen", "Steffen", "Stevan",
"Stephan", "Stefan", "Steffan"]

I know which I'd rather type.  'Course, if you can use a ready-built
list of names...

Iain




More information about the Python-list mailing list