re.search - just skip it

rasdj at frontiernet.net rasdj at frontiernet.net
Wed Jan 26 10:47:16 EST 2005


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(lines[i]): del lines[i]
except IndexError:
open("z.sql","w").writelines(lines)

but output is:

SET2_S_W CHAR(1) NOT NULL,
SET4_S_W CHAR(1) NOT NULL,
;

It should delete every, not every other!

thx,

RasDJ




More information about the Python-list mailing list