Re: Python and Regular Expressions

2010-04-12 Thread Neil Cerutti
On 2010-04-11, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Sat, 10 Apr 2010 10:11:07 -0700, Patrick Maupin wrote: On Apr 10, 11:35??am, Neil Cerutti ne...@norwich.edu wrote: On 2010-04-10, Patrick Maupin pmau...@gmail.com wrote: as Pyparsing. ??Which is all well and good,

Re: Python and Regular Expressions

2010-04-11 Thread Patrick Maupin
On Apr 10, 1:05 pm, Stefan Behnel stefan...@behnel.de wrote: Running a Python program in CPython eventually boils down to a sequence of commands being executed by the CPU. That doesn't mean you should write those commands manually, even if you can. It's perfectly ok to write the program in

Re: Python and Regular Expressions

2010-04-10 Thread Neil Cerutti
On 2010-04-08, Richard Lamboj richard.lam...@bilcom.at wrote: If someone knows good links to this thema, or can explain how parsers should/could work, please post it, or explain it. Thanks for the Informations and the Help! I liked Crenshaw's Let's Build a Compiler!. It's pretty trivial to

Re: Python and Regular Expressions

2010-04-10 Thread Patrick Maupin
On Apr 8, 5:13 am, Nobody nob...@nowhere.com wrote: On Wed, 07 Apr 2010 18:25:36 -0700, Patrick Maupin wrote: Regular expressions != Parsers True, but lots of parsers *use* regular expressions in their tokenizers.  In fact, if you have a pure Python parser, you can often get huge

Re: Python and Regular Expressions

2010-04-10 Thread Neil Cerutti
On 2010-04-10, Patrick Maupin pmau...@gmail.com wrote: Trust me, I already knew that. But what you just wrote is a much more useful thing to tell the OP than Every time someone tries to parse nested structures using regular expressions, Jamie Zawinski kills a puppy which is what I was

Re: Python and Regular Expressions

2010-04-10 Thread Patrick Maupin
On Apr 10, 11:35 am, Neil Cerutti ne...@norwich.edu wrote: On 2010-04-10, Patrick Maupin pmau...@gmail.com wrote: as Pyparsing.  Which is all well and good, except then the OP will download pyparsing, take a look, realize that it uses regexps under the hood, and possibly be very confused.

Re: Python and Regular Expressions

2010-04-10 Thread Stefan Behnel
Patrick Maupin, 10.04.2010 19:11: On Apr 10, 11:35 am, Neil Ceruttine...@norwich.edu wrote: On 2010-04-10, Patrick Maupinpmau...@gmail.com wrote: as Pyparsing. Which is all well and good, except then the OP will download pyparsing, take a look, realize that it uses regexps under the hood,

Re: Python and Regular Expressions

2010-04-10 Thread Ethan Furman
Stefan Behnel wrote: Patrick Maupin, 10.04.2010 19:11: On Apr 10, 11:35 am, Neil Ceruttine...@norwich.edu wrote: On 2010-04-10, Patrick Maupinpmau...@gmail.com wrote: as Pyparsing. Which is all well and good, except then the OP will download pyparsing, take a look, realize that it uses

Re: Python and Regular Expressions

2010-04-10 Thread Steven D'Aprano
On Sat, 10 Apr 2010 10:11:07 -0700, Patrick Maupin wrote: On Apr 10, 11:35 am, Neil Cerutti ne...@norwich.edu wrote: On 2010-04-10, Patrick Maupin pmau...@gmail.com wrote: as Pyparsing.  Which is all well and good, except then the OP will download pyparsing, take a look, realize that it

Re: Python and Regular Expressions

2010-04-10 Thread Paul Rubin
Steven D'Aprano st...@remove-this-cybersource.com.au writes: As entertaining as this is, the analogy is rubbish. Skis are far too simple to use as an analogy for a parser (he says, having never seen skis up close in his life *wink*). Have you looked at PyParsing's source code? Regexes are

Re: Python and Regular Expressions

2010-04-10 Thread Paul McGuire
On Apr 10, 8:38 pm, Paul Rubin no.em...@nospam.invalid wrote: The impression that I have (from a distance) is that Pyparsing is a good interface abstraction with a kludgy and slow implementation.  That the implementation uses regexps just goes to show how kludgy it is.  One hopes that someday

Re: Python and Regular Expressions

2010-04-08 Thread Nobody
On Wed, 07 Apr 2010 18:25:36 -0700, Patrick Maupin wrote: Regular expressions != Parsers True, but lots of parsers *use* regular expressions in their tokenizers. In fact, if you have a pure Python parser, you can often get huge performance gains by rearranging your code slightly so that

Re: Python and Regular Expressions

2010-04-08 Thread Richard Lamboj
At the moment i have less time, so its painful to read about parsing, but it is quite interessting. I have taken a look at the different Parsing Modules and i'am reading the Source Code to understand how they Work. Since Yesterday i'am writing on my own small Engine - Just for Fun and

Re: Python and Regular Expressions

2010-04-08 Thread Charles
Nobody nob...@nowhere.com wrote in message news:pan.2010.04.08.10.12.59.594...@nowhere.com... On Wed, 07 Apr 2010 18:25:36 -0700, Patrick Maupin wrote: Regular expressions != Parsers True, but lots of parsers *use* regular expressions in their tokenizers. In fact, if you have a pure

Python and Regular Expressions

2010-04-07 Thread Richard Lamboj
Hello, i want to parse this String: version 3.5.1 { $pid_dir = /opt/samba-3.5.1/var/locks/ $bin_dir = /opt/samba-3.5.1/bin/ service smbd { bin = ${bin_dir}smbd -D pid = ${pid_dir}smbd.pid } service nmbd {

Re: Python and Regular Expressions

2010-04-07 Thread Chris Rebert
On Wed, Apr 7, 2010 at 1:37 AM, Richard Lamboj richard.lam...@bilcom.at wrote: i want to parse this String: version 3.5.1 {        $pid_dir = /opt/samba-3.5.1/var/locks/        $bin_dir = /opt/samba-3.5.1/bin/        service smbd {                bin = ${bin_dir}smbd -D                

Re: Python and Regular Expressions

2010-04-07 Thread Bruno Desthuilliers
Richard Lamboj a écrit : Hello, i want to parse this String: version 3.5.1 { $pid_dir = /opt/samba-3.5.1/var/locks/ $bin_dir = /opt/samba-3.5.1/bin/ service smbd { bin = ${bin_dir}smbd -D pid = ${pid_dir}smbd.pid }

Re: Python and Regular Expressions

2010-04-07 Thread Richard Lamboj
Am Wednesday 07 April 2010 10:52:14 schrieb Chris Rebert: On Wed, Apr 7, 2010 at 1:37 AM, Richard Lamboj richard.lam...@bilcom.at wrote: i want to parse this String: version 3.5.1 {        $pid_dir = /opt/samba-3.5.1/var/locks/        $bin_dir = /opt/samba-3.5.1/bin/        

Re: Python and Regular Expressions

2010-04-07 Thread Patrick Maupin
On Apr 7, 3:52 am, Chris Rebert c...@rebertia.com wrote: Regular expressions != Parsers True, but lots of parsers *use* regular expressions in their tokenizers. In fact, if you have a pure Python parser, you can often get huge performance gains by rearranging your code slightly so that you can

Re: How to do this in python with regular expressions

2007-05-27 Thread snorble
On May 25, 6:51 am, Jia Lu [EMAIL PROTECTED] wrote: Hi all I'm trying to parsing html with re module. html = TABLE BORDER=1 cellspacing=0 cellpadding=2 TR TH nowrapDATA1/THTH nowrapDATA2/HTTH nowrapDATA3/ HTTHDATA4/TH /TR TRTDDATA5/TDTDDATA6/TDTDDATA7/TDTDDATA8/TD/TR /TABLE

How to do this in python with regular expressions

2007-05-25 Thread Jia Lu
Hi all I'm trying to parsing html with re module. html = TABLE BORDER=1 cellspacing=0 cellpadding=2 TR TH nowrapDATA1/THTH nowrapDATA2/HTTH nowrapDATA3/ HTTHDATA4/TH /TR TRTDDATA5/TDTDDATA6/TDTDDATA7/TDTDDATA8/TD/TR /TABLE I want to get DATA1-8 from that string.(DATA maybe not english

Re: How to do this in python with regular expressions

2007-05-25 Thread Thorsten Kampe
* Jia Lu (25 May 2007 04:51:35 -0700) I'm trying to parsing html with re module. [...] Can anyone tell me how to do it with regular expression in python? Just don't. Use an HTML parser like BeautifulSoup -- http://mail.python.org/mailman/listinfo/python-list

Re: How to do this in python with regular expressions

2007-05-25 Thread Mattia Gentilini
Thorsten Kampe ha scritto: I'm trying to parsing html with re module. Just don't. Use an HTML parser like BeautifulSoup Or HTMLParser/htmllib -- |\/|55: Mattia Gentilini e 55 = log2(che_palle_sta_storia) (by mezzo) |/_| ETICS project at CNAF, INFN, Bologna, Italy |\/| www.getfirefox.com

Re: How to do this in python with regular expressions

2007-05-25 Thread Mattia Gentilini
Thorsten Kampe ha scritto: I'm trying to parsing html with re module. Just don't. Use an HTML parser like BeautifulSoup Or HTMLParser/htmllib. of course you can mix those and re, it'll be easier than re only. -- |\/|55: Mattia Gentilini e 55 = log2(che_palle_sta_storia) (by mezzo) |/_| ETICS