On Tue, 15 Feb 2005 18:03:57 +0000, Max Noel <[EMAIL PROTECTED]> wrote: > > On Feb 15, 2005, at 17:19, Ron Nixon wrote: > > > Thanks to everyone who replied to my post. All of your > > suggestions seem to work. My thanks > > > > Ron > > Watch out, though, for all of this to work flawlessly you first have > to remove all punctuation (either with regexes or with multiple > foo.replace('[symbol]', '')), and to remove the case of each word > (foo.upper() or foo.lower() will do).
To remove all punctuation from the beginning and end of words, at least in 2.4, you can just use: word.strip('.!?\n\t ') plus any other characters that you'd like to strip. In action: >>> word = "?testing..!.\n\t " >>> word.strip('?.!\n\t ') 'testing' Peace Bill Mill bill.mill at gmail.com > > -- Max > maxnoel_fr at yahoo dot fr -- ICQ #85274019 > "Look at you hacker... A pathetic creature of meat and bone, panting > and sweating as you run through my corridors... How can you challenge a > perfect, immortal machine?" > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor