Pattern matching with string and list
BartlebyScrivener
rpdooling at gmail.com
Tue Dec 13 08:28:08 EST 2005
More information about the Python-list mailing list
Tue Dec 13 08:28:08 EST 2005
- Previous message (by thread): Pattern matching with string and list
- Next message (by thread): Pattern matching with string and list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Taking you literally, I'm not sure you need regex. If you know or can
find position n, then can't you just:
sentence = "the color is $red"
patterns = ["blue","red","yellow"]
pos = sentence.find("$")
for x in patterns:
if x==sentence[pos+1:]:
print x, pos+1
But maybe I'm oversimplifying.
rpd
- Previous message (by thread): Pattern matching with string and list
- Next message (by thread): Pattern matching with string and list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list