[Tutor] help with re module and parsing data

vineeth vineethrakesh at gmail.com
Mon Mar 7 08:54:30 CET 2011

Hello all I am doing some analysis on my trace file. I am finding the 
lines Recvd-Content and Published-Content. I am able to find those lines 
but the re module as predicted just gives the word that is being 
searched. But I require the entire  line similar to a grep in unix. Can 
some one tell me how to do this. I am doing the following way.

import re
file = open('file.txt','r')
file2 = open('newfile.txt','w')

LineFile = ' '

for line in file:
     LineFile += line

StripRcvdCnt = re.compile('(P\w+\S\Content|Re\w+\S\Content)')

FindRcvdCnt = re.findall(StripRcvdCnt, LineFile)

for SrcStr in FindRcvdCnt:


More information about the Tutor mailing list