[Tutor] Re: lists in re?

Andreas Zwinkau andi at buxach.de
Sun Sep 7 21:53:51 EDT 2003


Thanks for answering, Andrei

> If you mean you want to make a list of re's and apply them all inside
> a loop (or something like that): sure, why not? You can put anything
> you like in lists or dictionaries.
Not exactly, i learned something from your example, but i thought about
something like
parser = re.compile(["[abc]","abc","[A-Z]"])
parsedString = parser.replace(["-\\1-","def","[A-Z]"], string2parse)

lets say we have a dictionary for all replacement actions:
{"[abc]":"-\\1-", "abc":"def","[A-Z]":"_\\1_"}
how would you use this on "abBabcAbCC"?

-- 
mfg
Andreas Zwinkau
 | web: andi.dasstellenwirinsinternet.de
 | mail: andi at buxach.de
 | jabber: beza1e1 at amessage.de



More information about the Tutor mailing list