Re: [Tutor] Optional groups in RE's

2009-04-11 Thread Kent Johnson
On Sat, Apr 11, 2009 at 10:06 PM, Moos Heintzen wrote: > Mark Tolonen wrote: >> Your data looks like XML.  If it is actually well-formed XML, have you tried >> ElementTree? > > It is XML. I used minidom from xml.dom, and it worked fine, except it > was ~16 times slower. I'm parsing a ~70mb file,

Re: [Tutor] Optional groups in RE's

2009-04-11 Thread Moos Heintzen
Mark Tolonen wrote: > Your data looks like XML.  If it is actually well-formed XML, have you tried > ElementTree? It is XML. I used minidom from xml.dom, and it worked fine, except it was ~16 times slower. I'm parsing a ~70mb file, and the difference is 3 minutes to 10 seconds with re's. I used

Re: [Tutor] Optional groups in RE's

2009-04-11 Thread Kent Johnson
On Sat, Apr 11, 2009 at 6:46 PM, Moos Heintzen wrote: > Hello Tutors! > > I was trying to make some groups optional in a regular expression, but > I couldn't do it. > > For example, I have the string: > data = "42 sdlfks d f60 sdf sdf   Title" > > and the pattern: pattern = "(

Re: [Tutor] Optional groups in RE's

2009-04-11 Thread Mark Tolonen
"Moos Heintzen" wrote in message news:7b13ba330904111546n21d90202i7572a75c55b02...@mail.gmail.com... > Hello Tutors! > > I was trying to make some groups optional in a regular expression, but > I couldn't do it. > > For example, I have the string: > data = "42 sdlfks d f60 sdf sdf Tit

[Tutor] Optional groups in RE's

2009-04-11 Thread Moos Heintzen
Hello Tutors! I was trying to make some groups optional in a regular expression, but I couldn't do it. For example, I have the string: >>> data = "42 sdlfks d f60 sdf sdf >>> Title" and the pattern: >>> pattern = "(.*?).*?(.*?).*?(.*?)" This works when all the groups are present. >>> re.sea