How is it possible to obtain the line numbers of all the text snippets matching a given regexp, within a file?
regexp
file_content = f.rea
import re reg="ha*" count=0 f = open(somefile,'r') while True: line= f.readline() if not line: break else: count+=1 if re.search(reg,line): print count,line