Re: re.search - just skip it

2005-01-26 Thread Kent Johnson
[EMAIL PROTECTED] wrote: Input is this: SET1_S_W CHAR(1) NOT NULL, SET2_S_W CHAR(1) NOT NULL, SET3_S_W CHAR(1) NOT NULL, SET4_S_W CHAR(1) NOT NULL, ; .py says: import re, string, sys s_ora = re.compile('.*S_W.*') lines = open("y.sql").readlines() for i in range(len(lines)): try: if s_ora.search(lin

Re: re.search - just skip it

2005-01-26 Thread Fredrik Lundh
<[EMAIL PROTECTED]> wrote: > but output is: > > SET2_S_W CHAR(1) NOT NULL, > SET4_S_W CHAR(1) NOT NULL, > > It should delete every, not every other! for i in range(len(lines)): try: if s_ora.search(lines[i]): del lines[i] except IndexError: ... when you loop over a range,

Re: re.search - just skip it

2005-01-26 Thread Duncan Booth
wrote: > Input is this: > > SET1_S_W CHAR(1) NOT NULL, > SET2_S_W CHAR(1) NOT NULL, > SET3_S_W CHAR(1) NOT NULL, > SET4_S_W CHAR(1) NOT NULL, > ; > > .py says: > > import re, string, sys > s_ora = re.compile('.*S_W.*') > lines = open("y.sql").readlines() > for i in range(len(lines)): > try: >