Re: idiom for RE matching

2007-07-25 Thread Gordon Airporte
Ben Finney wrote: > > Not that I want to pick on you; I just don't want something wrong > labelled as "proper" to go unchallenged in the archives :-) Oh gawd :-P I swear I have it right in the actual file! heh. Copy and paste something that's compiled kids, copy and paste. -- http://mail.pytho

Re: idiom for RE matching

2007-07-25 Thread Ben Finney
Gordon Airporte <[EMAIL PROTECTED]> writes: > The actual code uses the proper 'if foo in line or if bar in line:' > form. >>> line = "spam eggs ham" >>> foo = "spam" >>> bar = "sausage" >>> if foo in line or if bar in line: File "", line 1 if foo in line or if bar in

Re: idiom for RE matching

2007-07-25 Thread Wildemar Wildenburger
Gordon Airporte wrote: > Yes, that's pseudo code even though I didn't really mean it that way > when I typed it. The actual code uses the proper 'if foo in line or if > bar in line:' form. > One 'if' too many. /W -- http://mail.python.org/mailman/listinfo/python-list

Re: idiom for RE matching

2007-07-25 Thread Gordon Airporte
Miles wrote: > On 7/24/07, Gordon Airporte <[EMAIL PROTECTED]> wrote: >> I did already find that it speeds things up to pre-test a line like >> >> if 'bets' or 'calls' or 'raises' in line: >> run the appropriate re's > > Be careful: unless this is just pseudocode, this Python doesn't do >

Re: idiom for RE matching

2007-07-25 Thread Ben Finney
Gordon Airporte <[EMAIL PROTECTED]> writes: > I did already find that it speeds things up to pre-test a line like > > if 'bets' or 'calls' or 'raises' in line: > run the appropriate re's > > which isn't very pretty at all Nor does it work the way you might suppose: >>> line = "foo ca

Re: idiom for RE matching

2007-07-24 Thread Gabriel Genellina
En Wed, 25 Jul 2007 00:02:51 -0300, Gordon Airporte <[EMAIL PROTECTED]> escribió: > Gabriel Genellina wrote: > >> As is often the case, a regular expression is NOT the right tool to use >> in this case. > > Very interesting, thank you. I think 'pattern matching' and I > automatically think 'regu

Re: idiom for RE matching

2007-07-24 Thread Miles
On 7/24/07, Gordon Airporte <[EMAIL PROTECTED]> wrote: > I did already find that it speeds things up to pre-test a line like > > if 'bets' or 'calls' or 'raises' in line: > run the appropriate re's Be careful: unless this is just pseudocode, this Python doesn't do what you think it does; i

Re: idiom for RE matching

2007-07-24 Thread Gordon Airporte
Gabriel Genellina wrote: > As is often the case, a regular expression is NOT the right tool to use > in this case. > > --Gabriel Genellina Very interesting, thank you. I think 'pattern matching' and I automatically think 'regular expressions'. I did already find that it speeds things up to pre

Re: idiom for RE matching

2007-07-23 Thread Gabriel Genellina
En Tue, 24 Jul 2007 00:23:46 -0300, Gordon Airporte <[EMAIL PROTECTED]> escribió: > [EMAIL PROTECTED] wrote: >> if your search is not overly complicated, i think regexp is not >> needed. if you want, you can post a sample what you want to search, >> and some sample input. > > I'm afraid it's pre

Re: idiom for RE matching

2007-07-23 Thread Gordon Airporte
[EMAIL PROTECTED] wrote: > if your search is not overly complicated, i think regexp is not > needed. if you want, you can post a sample what you want to search, > and some sample input. I'm afraid it's pretty complicated :-). I'm doing analysis of hand histories that online poker sites leave for

Re: idiom for RE matching

2007-07-22 Thread mik3l3374
On Jul 19, 12:52 pm, Gordon Airporte <[EMAIL PROTECTED]> wrote: > I have some code which relies on running each line of a file through a > large number of regexes which may or may not apply. For each pattern I > want to match I've been writing > > gotit = mypattern.findall(line) > if gotit: >

Re: idiom for RE matching

2007-07-22 Thread Gordon Airporte
[EMAIL PROTECTED] wrote: > Have you read and understood what MULTILINE means in the manual > section on re syntax? > > Essentially, you can make a single pattern which tests a match against > each line. > > -- Michael Dillon No, I have not looked into this - thank you. RE's are hard enough to g

Re: idiom for RE matching

2007-07-22 Thread memracom
On 19 Jul, 05:52, Gordon Airporte <[EMAIL PROTECTED]> wrote: > I have some code which relies on running each line of a file through a > large number of regexes which may or may not apply. Have you read and understood what MULTILINE means in the manual section on re syntax? Essentially, you can ma

Re: idiom for RE matching

2007-07-19 Thread Reddy
On 7/19/07, Gordon Airporte <[EMAIL PROTECTED]> wrote: I have some code which relies on running each line of a file through a large number of regexes which may or may not apply. For each pattern I want to match I've been writing gotit = mypattern.findall(line) Try to use iterator function f

Re: idiom for RE matching

2007-07-19 Thread Roger Miller
On Jul 18, 6:52 pm, Gordon Airporte <[EMAIL PROTECTED]> wrote: > ... > I've also been assuming that using the re functions that create match > objects is slower/heavier than dealing with the simple list returned by > findall(). I've profiled it and these matches are the biggest part of > the runni

idiom for RE matching

2007-07-18 Thread Gordon Airporte
I have some code which relies on running each line of a file through a large number of regexes which may or may not apply. For each pattern I want to match I've been writing gotit = mypattern.findall(line) if gotit: gotit = gotit[0] ...do whatever else... This seems kind of clun