On 7/18/07, Tiger12506 <[EMAIL PROTECTED]> wrote:

>I sent a sample of the file "testin.txt" in the last email.  Here are the
> lines themsevles:

Oh! Sorry. I didn't look in the attachments - I expected the lines in the
email. My mistake.
Try this ~~   :-P


##############################
import re

infile = open("testin.txt","r")
outfile = open("out.txt","w")

patt = re.compile(r".*src=([\d\.]*) dst=([\d\.]*).*")

for line in infile:
  m = patt.match(line)
  if m:
    outfile.write("src=%s dst=%s\n"%m.groups())

infile.close()
outfile.close()
#############################

Seeing the input file makes me wonder if regular expressions is over kill
in
this instance.

JS


Hi there,

     If you are looking for one ip address, and only one ip address, you
might want to consider:

for line in input_file:
    if "10.52.10.10" in line:
          outfile.writeline(line)

outfile.close()

Is that what you want?
-Tino
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to