Checking if string starts with list element
Alex
cut_me_out at hotmail.com
Mon Aug 14 11:43:22 EDT 2000
> I want to know whether my sting *starts with* one of the strings in my
> list.
The strings all seem to be words; can you get the first word in the
target string, and see if that is in the list?
#Untested
import re
first_word = re.match('.*\b', us, word)
if first_word in romans:
# do stuff.
pass
Alex.
> If you are not the intended recipient, any disclosure, copying,
> distribution, or any action taken or omitted to be taken in reliance
> on it, is prohibited and may be unlawful.
Cool, are you going to sue me, now? <wink>
--
To succeed in the world it is not enough to be stupid; you must also be
well-mannered. -- Voltaire
More information about the Python-list
mailing list