Re: searching for the number of occurences of a string

2006-03-05 Thread marek . rocki
> hi; > say i have a text file with a string ( say '(XYZ)') and I want to find > the number of line where this string has occured. What is the best way > to do that? I would suggest: # Read file contents lines = file('filename.txt').readlines() # Extract first line number containing 'XYZ' string

Re: searching for the number of occurences of a string

2006-03-05 Thread James Stroud
M.N.A.Smadi wrote: > hi; > say i have a text file with a string ( say '(XYZ)') and I want to find > the number of line where this string has occured. What is the best way > to do that? > > what about if that string was say a 0 with leading and trailing white > spaces, would that be any differen

Re: searching for the number of occurences of a string

2006-03-05 Thread James Stroud
M.N.A.Smadi wrote: > hi; > say i have a text file with a string ( say '(XYZ)') and I want to find > the number of line where this string has occured. What is the best way > to do that? > > what about if that string was say a 0 with leading and trailing white > spaces, would that be any differen