Thread: [Pyparsing] SkipTo problem
Brought to you by:
ptmcg
From: Michele P. <mic...@un...> - 2005-04-21 14:27:27
|
I have a problem with the function SkipTo. With this sample code, I want to have only a part of my data, but the function SkipTo return me all the data. What's wrong? Thanks, Michele Petrazzo Italy This is what I need [':DESCR\n fw = Firewall\n net = Ethernet config'] This is what pyparsing return me: [':LIST\n fw = 1\n net = 1', '::LIST\n\n:DESCR\n fw = Firewall\n net = Ethernet config'] data = """ :LIST fw = 1 net = 1 ::LIST :DESCR fw = Firewall net = Ethernet config ::DESCR """ LIST = Literal(':LIST') LIST_END = Literal('::LIST').suppress() DESCR = Literal(':DESCR') DESCR_END = Literal('::DESCR').suppress() v = SkipTo(LIST_END) + SkipTo(DESCR_END) print v.parseString(data) |