Re: regexp match string with word1 and not word2

2007-05-02 Thread Ant
On May 2, 9:17 am, Flyzone <[EMAIL PROTECTED]> wrote: > On 30 Apr, 20:00, Steven Bethard <[EMAIL PROTECTED]> wrote: ... > Maybe a right approach will be another if after the first one? Like: >for y in range(0, len(skip_lst) ): > if (re.search(skip_lst[y], line)): >

Re: regexp match string with word1 and not word2

2007-05-02 Thread Flyzone
On 30 Apr, 20:00, Steven Bethard <[EMAIL PROTECTED]> wrote: > Well then it seems like you might want to rethink this rule-file > approach since your problem is clearly not amenable to regular expressions. [cut] > That said, here's a regexp that might work:: > ((?!two:).)*one((?!two:).)* > That

Re: regexp match string with word1 and not word2

2007-04-30 Thread MRAB
On Apr 30, 6:49 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, Flyzone wrote: > > for y in range(0, len(skip_lst) ): > > if (re.search(skip_lst[y], line)): > > skip=1 > >break > > Pleas

Re: regexp match string with word1 and not word2

2007-04-30 Thread Steven Bethard
Flyzone wrote: > On 30 Apr, 17:11, Steven Bethard <[EMAIL PROTECTED]> wrote: > >> You don't need a regexp:; > > I need a regexp.i'm parsing a file with a rule-file that contains > also regexp and strings too Well then it seems like you might want to rethink this rule-file approach since

Re: regexp match string with word1 and not word2

2007-04-30 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Flyzone wrote: > for y in range(0, len(skip_lst) ): > if (re.search(skip_lst[y], line)): > skip=1 >break Please try to avoid unnecessary indexes:: for regexp in skip_list: if re.sea

Re: regexp match string with word1 and not word2

2007-04-30 Thread Carsten Haese
On Mon, 2007-04-30 at 08:22 -0700, Flyzone wrote: > On 30 Apr, 17:11, Steven Bethard <[EMAIL PROTECTED]> wrote: > > > You don't need a regexp:; > > I need a regexp.i'm parsing a file with a rule-file that contains > also regexp and strings too That was not at all evident from your origin

Re: regexp match string with word1 and not word2

2007-04-30 Thread Flyzone
On 30 Apr, 17:11, Steven Bethard <[EMAIL PROTECTED]> wrote: > You don't need a regexp:; I need a regexp.i'm parsing a file with a rule-file that contains also regexp and strings too Read my post to James Stroud. -- http://mail.python.org/mailman/listinfo/python-list

Re: regexp match string with word1 and not word2

2007-04-30 Thread Flyzone
James Stroud ha scritto: > The P.S: suggests homework, but this can't be homework because python > regex won't do this, so your teacher gets an F if its homework. You Not a homework, but a "workwork" :-) I'm writing a script to parse logfiles, and I have began to study python for this (bash was t

Re: regexp match string with word1 and not word2

2007-04-30 Thread Steven Bethard
Flyzone wrote: > Hello, > i have again problem with regexp :-P > I need to match all lines that contain one word but not contain > another. > Like to do "grep one | grep -v two:" You don't need a regexp:; if 'one' in line and 'two:' not in line: ... do something... STeVe -- http:/

Re: regexp match string with word1 and not word2

2007-04-30 Thread James Stroud
Flyzone wrote: > P.S: i can't have more re.search, so [clip] This reminds me of a quote by the Great Researcher Roy Garcia: If it worked the first time, they'd just call it "search". James -- http://mail.python.org/mailman/listinfo/python-list

Re: regexp match string with word1 and not word2

2007-04-30 Thread James Stroud
Flyzone wrote: > Hello, > i have again problem with regexp :-P > I need to match all lines that contain one word but not contain > another. > Like to do "grep one | grep -v two:" > The syntax of the string is: > (any printable char)two:(any printable char)one(any printable char) > Example: > Apr 30

regexp match string with word1 and not word2

2007-04-30 Thread Flyzone
Hello, i have again problem with regexp :-P I need to match all lines that contain one word but not contain another. Like to do "grep one | grep -v two:" The syntax of the string is: (any printable char)two:(any printable char)one(any printable char) Example: Apr 30 00:00:09 v890neg0 two: [ID 70291