Re: Newbie needs help with regex strings

2005-12-14 Thread Paul McGuire
This isn't a regex solution, but uses pyparsing instead. Pyparsing helps you construct recursive-descent parsers, and maintains a code structure that is easy to compose, read, understand, maintain, and remember what you did 6-months after you wrote it in the first place. Download pyparsing at

Re: Newbie needs help with regex strings

2005-12-14 Thread Fredrik Lundh
Scott wrote: I have a file with lines in the following format. pie=apple,quantity=1,cooked=yes,ingredients='sugar and cinnamon' Pie=peach,quantity=2,ingredients='peaches,powdered sugar' Pie=cherry,quantity=3,cooked=no,price=5,ingredients='cherries and sugar' I would like to pull out some

Re: Newbie needs help with regex strings

2005-12-14 Thread Christopher Subich
Paul McGuire wrote: This isn't a regex solution, but uses pyparsing instead. Pyparsing helps you construct recursive-descent parsers, and maintains a code structure that is easy to compose, read, understand, maintain, and remember what you did 6-months after you wrote it in the first place.

Re: Newbie needs help with regex strings

2005-12-14 Thread Dennis Benzinger
Catalina Scott A Contr AFCA/EVEO schrieb: I have a file with lines in the following format. pie=apple,quantity=1,cooked=yes,ingredients='sugar and cinnamon' Pie=peach,quantity=2,ingredients='peaches,powdered sugar' Pie=cherry,quantity=3,cooked=no,price=5,ingredients='cherries and sugar' I

Re: Newbie needs help with regex strings

2005-12-14 Thread Dennis Benzinger
Christopher Subich schrieb: Paul McGuire wrote: [...] For the example listed, pyparsing is even overkill; the OP should probably use the csv module. But the OP wants to parse lines with key=value pairs, not simply lines with comma separated values. Using the csv module will just separate

Re: Newbie needs help with regex strings

2005-12-14 Thread Gerard Flanagan
Fredrik Lundh wrote: Scott wrote: I have a file with lines in the following format. pie=apple,quantity=1,cooked=yes,ingredients='sugar and cinnamon' Pie=peach,quantity=2,ingredients='peaches,powdered sugar' Pie=cherry,quantity=3,cooked=no,price=5,ingredients='cherries and sugar' I

Re: Newbie needs help with regex strings

2005-12-14 Thread Michael Spencer
Dennis Benzinger wrote: Christopher Subich schrieb: Paul McGuire wrote: [...] For the example listed, pyparsing is even overkill; the OP should probably use the csv module. But the OP wants to parse lines with key=value pairs, not simply lines with comma separated values. Using the csv

Re: Newbie needs help with regex strings

2005-12-14 Thread Michael Spencer
Catalina Scott A Contr AFCA/EVEO wrote: I have a file with lines in the following format. pie=apple,quantity=1,cooked=yes,ingredients='sugar and cinnamon' Pie=peach,quantity=2,ingredients='peaches,powdered sugar' Pie=cherry,quantity=3,cooked=no,price=5,ingredients='cherries and sugar' I