Shawn, Tim ,Jay
 
many thanks,
 
It looks like there are many ways this problem can be approached

either by using  regex or a tokens 

Tim I'm not familiar with your solution, but will learn about that method also
Jay, what do you mean by regex comes with a lot of overhead?

--Brian
 
 

________________________________

From: [EMAIL PROTECTED] on behalf of Shawn Milochik
Sent: Mon 8/20/2007 3:07 PM
To: python-list@python.org
Subject: Re: reading a line in file



Hopefully this will help (using your input file)

#!/usr/bin/env python
import re
buildinfo = "input.txt"
input = open(buildinfo, 'r')

regex = re.compile(r"^\s*build.number=(\d+)\s*$")

for line in input:
    if re.search(regex, line):
        print line
        buildNum = re.sub(r"^\s*build.number=(\d+)\s*$", "\\1", line)
        print line
        print buildNum
--
http://mail.python.org/mailman/listinfo/python-list


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to