This seems like it should be so simple, but i am having some serious issues. All i want to do is see if the user input matches a 2 letter expression. I guess my biggest problem i have is that i am not very familiar with the re library and the documentation does not really help me too much.
This is what i have tried so far:
try 1
if re.match(sys.argv[3], "GL", re.I):
input_file_path = "V:\\test"
try 2
if re.ignorecase(sys.argv[3], "GL"):
input_file_path = "V:\\test"
try 3
if sys.argv[3] == "GL":
input_file_path = "V:\\test"
The way i call the program to run: filename.py tester test GL
“tester” and “test” are not really used yet.
EDIT: I found my main problem. I was calling a bunch of if statements rather than elif. So the last one that said else: exit() always got hit (cause i was testing the first if). rookie mistake
Just convert the string to test to lowercase before comparing and you should be fine:
More notably, regular expressions are not the right tool for this job.