Larry Bates wrote:

vowel_regexp = oneOf("a aa i ii u uu".split())  # yielding r'(aa|a|uu|
u|ii|i)'

Is there a public module available for this purpose?

Perhaps I'm missing something but your function call oneOf(...) is longer than than actually specifying the result.

You can certainly write quite easily:

def oneOf(s):
    return "|".join(s.split())

"|" works strictly from left to right, so that doesn't quite work since it doesn't place "aa" before "a". a simple reverse sort will take care of that:

    return "|".join(sorted(s.split(), reverse=True))

you may also want to do re.escape on all the words, to avoid surprises when the choices contain special characters.

</F>

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to