Checking if string starts with list element
François Granger
francois.granger at free.fr
Tue Aug 15 06:33:45 EDT 2000
Simon Brunning <SBrunning at trisystems.co.uk> wrote:
> > #Untested
> > import re
> > first_word = re.match('.*\b', us, word)
> > if first_word in romans:
> > # do stuff.
> > pass
> >
> Uh, interesting. Yes, I'm looking to match first words. I think that re is
> the way to go.
Simpler ???
#Untested
import string
first_word = string.split(us, none, 1)
if first_word in romans:
# do stuff.
pass
--
"Do unto others as you would have done unto you" - unknown
More information about the Python-list
mailing list