[Tutor] Re: lists in re?

Andreas Zwinkau andi at buxach.de
Tue Sep 9 14:39:01 EDT 2003


> parser = [ re.compile(item) for item in ["[abc]","abc","[A-Z]"] ]
I'm not used to such "complex" constructs, but well, I can work with it.

> Any chance of an example of what you're putting into it and what the 
> code is supposed to make out of it? It would be most useful if you'd
> put in some *real* examples, because a key-value pair like "abc":"def"
> is a bit too abstract for me to understand its purpose.
Do you know what a Wiki is? I have some user text with abstract text
formations e.g. __underlined__ 
These should be processed into HTML <u>underlined</u> 

There are some more rules.
''italic''                                  -> <i>italic</i>
**bold**                              -> <b>bold</b>
[word]                                  -> <a href="word">word</a>
[image.gif]                           -> <img src="image.gif" />
[http://google.com|Google] -> <a href="http://google.com>Google</a> 
http://slashdot.org               -> <a
href="http://slashdot.org">http://slashdot.org</a>

If this gets more and more, i thought a dictionary would be the best way
to define it in a obvious way. So this dict needs to be fed to the re
module, but instead of processing each item, i wanted to re.compile it
in one piece.

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



More information about the Tutor mailing list