Concerning Regular Expressions

Tempo bradfordh at gmail.com
Sun Jan 29 23:55:45 EST 2006


You are right that my move towards regular expressions was way
premature, but also this post may too turn out to be a little
premature. I guessed and checked myself a way to accomplish what I
needed and I will include it in this post. But first Alex (doesn't have
to be Alex) could you tell me if your snipplet and mine would be near
perfect subsitutes for one another? I believe they accomplish the same
task of looking for 'R0 -' in the list 'lines', however, as you have
guessed, I do not know my way around Python very well yet. Here is my
snipplet:

log = open('C:\log_0.txt')
lines = log.readlines()
import re
for line in lines:
    R = re.search(r'^R0', line)
    if R != None:
        n = 1
        print n
import time
time.sleep(3)
log.close()




More information about the Python-list mailing list