Trying to implement the grep command in python. The program should take arguments when initializing, for example, python grep.py something -v file.txt
. I do this thanks to the sys
library, or rather sys.args
Also this program should support regular expressions that are placed in double quotes python grep.py "regex" file.txt
. But during initialization, double quotes fly off the arguments on both sides, leaving them bare. The only solution I found is to put three quotes around the regular expression python grep.py """regex""" file.txt
.
Tell me how to get around this.