I am trying to implement grep to just increase my knowledge
about regular expression.

Below is the program usage:
python test.py -i Documents/linux/linux/ -s '\w+_readalarm*'

However, due to my lack of knowledge about string handling
in python, I am getting wrong results.

def read_file(file, pattern):
   with open(file, 'r') as outfile:
     for line in outfile:
       match = re.compile(str(pattern)).match(line)
       if match:
         print(file + " " + match.group())

Can someone let me know how can I pass regular expression
from command line?

Whole code: http://ideone.com/KxLJP2

Any other comments about the code are most welcome.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to