Paul McGuire wrote:
from re import *

Perhaps you intended "import re".

vowels = "aAeEiIoOuU"
cons = "bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ"
encodeRe = re.compile(r"([%s])[%s]\1" % (cons,vowels))
print encodeRe.sub(r"\1",s)

This is actually a little more complex than you asked - it will search
for any consonant-vowel-same_consonant triple, and replace it with the
leading consonant.  To meet your original request, change to:

from re import *

And again.

cons = "bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ"
encodeRe = re.compile(r"([%s])o\1" % cons)
print encodeRe.sub(r"\1",s)

Both print "prince".


No they don't. The result is "NameError: name 're' is not defined".
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to