From: Chuck E. <ec...@mi...> - 2001-04-10 17:48:47
|
I haven't studied your exact example in depth, but in general, I'm pretty confident that if you have a language with multiple, nested blocks, you really need a parser, probably a recursive descent parser. Usually these sit on top of a lexer that is based on regular expressions. You are no longer in the realm of simple regexes. Mwahahahaha! In fact, if I thought that my proposed template language could have been done with regexes, I probably would have done it a long time ago. PSP should be no different so you might look at the source there for hints. -Chuck At 10:47 AM 4/10/2001 -0700, Tavis Rudd wrote: >I weak on parsing and regexps, and need some tips. I'm not >sure if you'll like what I'm using this for but here goes: > >How do I make this RE work with the text below so that it >will snatch everything from the first ><templateFillerLogic>(.*?)</templateFillerLogic> >to the very last ><templateFillerLogic> *end *</templateFillerLogic> > >'logicBlockRE':re.compile( >r"<templateFillerLogic>(.*?)</templateFillerLogic>(.*?) ><templateFillerLogic> *end *</templateFillerLogic>"), >---------------------------------------- >## NOTE: ># [- is substituted with <templateFillerLogic> ># -] is substituted with </templateFillerLogic> > >[-if blarg-] > >[-for i in list2-] >.... >[-end-] > >{body} >{nestedTemplate} > >[-end-] |