Re: recording data between [ and ]

2005-04-21 Thread François Granger
Le 21/04/05 16:19, « rbt » <[EMAIL PROTECTED]> a écrit : > Peter Hansen wrote: >> rbt wrote: >> >>> Output from 'netstat -b' on a win2003 server will show what binary is >>> responsible for the connection. For example, it may list something >>> like this along with other connection specific data:

Re: recording data between [ and ]

2005-04-21 Thread jay graves
[EMAIL PROTECTED] wrote: > Beside rxb15, there is also redict, in the standard lib (Jay Graves > shows the HD path): > http://home.earthlink.net/~jasonrandharper/reverb.py I knew there was a newer one out there but my google skills failed me. Thanks for the link. -- http://mail.python.org/mailma

Re: recording data between [ and ]

2005-04-21 Thread bearophileHUGS
Diez B. Roggisch>But as the world is complex and people want solutions to their complex problems, IMHO programming will always be about such nitty gritty details.< REs are like assembly, but high-level languages show us that for a mammal there are (often) better (higher) ways to program a computer

Re: recording data between [ and ]

2005-04-21 Thread Jim Sizelove
Simon Brunning wrote: On 4/21/05, rbt <[EMAIL PROTECTED]> wrote: string.between(data,[,]) def between(data, start, end): return re.findall(re.escape(start) + r'([^]]*)'+ re.escape(end), data) That's cool! But it doesn't quite work if the end tag is not ']': >>> import re >>> def between(d

Re: recording data between [ and ]

2005-04-21 Thread Diez B. Roggisch
Fredrik Lundh wrote: > Diez B. Roggisch wrote: > >> Welcome to the wonderful world of programming. Regular expressions are >> what they are because they are modeled after a certain theory - that of >> finite state automata and their correspondence to certain classes of >> grammars. > > (except t

Re: recording data between [ and ]

2005-04-21 Thread jay graves
Paul McGuire wrote: > Jay - > Thanks for the pyparsing plug. NP. pyparsing is on my list of stuff to play around with. I'm just waiting for the proper problem to present itself. > Here is how the OP's program would look using pyparsing: And the exact reason that I could 'plug' pyparsing is tha

Re: recording data between [ and ]

2005-04-21 Thread Paul McGuire
Jay - Thanks for the pyparsing plug. Here is how the OP's program would look using pyparsing: import pyparsing fp = file('filename') data = fp.read() fp.close() foo = '''stuff [lsass.exe] [System] more stuff x [firefox.exe] .. ''' LBRACK = pyparsing.Literal("[").suppress() RBRACK

Re: recording data between [ and ]

2005-04-21 Thread jay graves
I haven't used either of these tools but they might help a little. http://lfw.org/python/rxb15.py http://pyparsing.sourceforge.net/ If you want to help building traditional regex patterns, I find programs like these to be invaluable. Tools/scripts/redemo.py in the python standard lib. http://kod

Re: recording data between [ and ]

2005-04-21 Thread Simon Brunning
On 4/21/05, rbt <[EMAIL PROTECTED]> wrote: > string.between(data,[,]) def between(data, start, end): return re.findall(re.escape(start) + r'([^]]*)'+ re.escape(end), data) foo = '''stuff [lsass.exe] [System] more stuff x [firefox.exe] .. ''' print between(foo, '[', ']') -- C

Re: recording data between [ and ]

2005-04-21 Thread rbt
Roy Smith wrote: Diez B. Roggisch <[EMAIL PROTECTED]> wrote: Yes, it does... may take me a few minutes to get my head around it though. Why do re's have to be so arcane and complicated... especially in Python? It's hard to preach 'ease of use' with stuff such as this in the language. Perhaps one da

Re: recording data between [ and ]

2005-04-21 Thread Roy Smith
Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >> Yes, it does... may take me a few minutes to get my head around it >> though. Why do re's have to be so arcane and complicated... especially >> in Python? >> >> It's hard to preach 'ease of use' with stuff such as this in the >> language. Perhaps one

Re: recording data between [ and ]

2005-04-21 Thread Fredrik Lundh
Diez B. Roggisch wrote: Welcome to the wonderful world of programming. Regular expressions are what they are because they are modeled after a certain theory - that of finite state automata and their correspondence to certain classes of grammars. (except that Python regexps are not always regular, o

Re: recording data between [ and ]

2005-04-21 Thread Diez B. Roggisch
> Yes, it does... may take me a few minutes to get my head around it > though. Why do re's have to be so arcane and complicated... especially > in Python? > > It's hard to preach 'ease of use' with stuff such as this in the > language. Perhaps one day it can be rolled up into something that > *rea

Re: recording data between [ and ]

2005-04-21 Thread rbt
Peter Hansen wrote: rbt wrote: Output from 'netstat -b' on a win2003 server will show what binary is responsible for the connection. For example, it may list something like this along with other connection specific data: [lsass.exe] [System] [firefox.exe] [iexplorer.exe] How might I process the

Re: recording data between [ and ]

2005-04-21 Thread Peter Hansen
rbt wrote: Output from 'netstat -b' on a win2003 server will show what binary is responsible for the connection. For example, it may list something like this along with other connection specific data: [lsass.exe] [System] [firefox.exe] [iexplorer.exe] How might I process the output so that anyth

recording data between [ and ]

2005-04-21 Thread rbt
Output from 'netstat -b' on a win2003 server will show what binary is responsible for the connection. For example, it may list something like this along with other connection specific data: [lsass.exe] [System] [firefox.exe] [iexplorer.exe] How might I process the output so that anything within