diff --git a/SSnR.py b/SSnR.py index 9d21328..5cbd62d 100755 --- a/SSnR.py +++ b/SSnR.py @@ -51,7 +51,7 @@ def main(): # Compile regex try: - ex = compile_regex(args["regex"]) + ex = compile_regex(args["regex"], args["ignore_case"]) except SyntaxError as exception: print("Error when compiling regex: " + str(exception)) return -1 @@ -63,7 +63,7 @@ def main(): filenames = [] if args["regex_input"] is not None: try: - input_ex = compile_regex(args["regex_input"]) + input_ex = compile_regex(args["regex_input"], False) except SyntaxError as exception: print("Error when compiling input regex: " + str(exception)) return -1 @@ -101,7 +101,7 @@ def main(): output_files = [] if args["regex_output"] is not None: if input_ex is None: - print("Error: Yu need a regex input file to use a regex output file") + print("Error: You need a regex input file to use a regex output file") return -1 for input_filename in filenames: try: @@ -163,12 +163,15 @@ def main(): search(ex, string, is_file) return 0 -def compile_regex(ex): +def compile_regex(ex, ignore_case): """ Compile regex :param ex: Regular expression """ - regex_compile = regex.compile(ex, regex.MULTILINE) + if ignore_case: + regex_compile = regex.compile(ex, regex.MULTILINE | regex.IGNORECASE) + else: + regex_compile = regex.compile(ex, regex.MULTILINE) if regex_compile is None: raise SyntaxError('Error in the regex')