Add case insensitive
Signed-off-by: Rémi BERTHO <remi.bertho@dalan.fr>
This commit is contained in:
parent
71426f81e1
commit
d29700239b
1 changed files with 8 additions and 5 deletions
11
SSnR.py
11
SSnR.py
|
@ -51,7 +51,7 @@ def main():
|
||||||
|
|
||||||
# Compile regex
|
# Compile regex
|
||||||
try:
|
try:
|
||||||
ex = compile_regex(args["regex"])
|
ex = compile_regex(args["regex"], args["ignore_case"])
|
||||||
except SyntaxError as exception:
|
except SyntaxError as exception:
|
||||||
print("Error when compiling regex: " + str(exception))
|
print("Error when compiling regex: " + str(exception))
|
||||||
return -1
|
return -1
|
||||||
|
@ -63,7 +63,7 @@ def main():
|
||||||
filenames = []
|
filenames = []
|
||||||
if args["regex_input"] is not None:
|
if args["regex_input"] is not None:
|
||||||
try:
|
try:
|
||||||
input_ex = compile_regex(args["regex_input"])
|
input_ex = compile_regex(args["regex_input"], False)
|
||||||
except SyntaxError as exception:
|
except SyntaxError as exception:
|
||||||
print("Error when compiling input regex: " + str(exception))
|
print("Error when compiling input regex: " + str(exception))
|
||||||
return -1
|
return -1
|
||||||
|
@ -101,7 +101,7 @@ def main():
|
||||||
output_files = []
|
output_files = []
|
||||||
if args["regex_output"] is not None:
|
if args["regex_output"] is not None:
|
||||||
if input_ex is 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
|
return -1
|
||||||
for input_filename in filenames:
|
for input_filename in filenames:
|
||||||
try:
|
try:
|
||||||
|
@ -163,11 +163,14 @@ def main():
|
||||||
search(ex, string, is_file)
|
search(ex, string, is_file)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def compile_regex(ex):
|
def compile_regex(ex, ignore_case):
|
||||||
"""
|
"""
|
||||||
Compile regex
|
Compile regex
|
||||||
:param ex: Regular expression
|
:param ex: Regular expression
|
||||||
"""
|
"""
|
||||||
|
if ignore_case:
|
||||||
|
regex_compile = regex.compile(ex, regex.MULTILINE | regex.IGNORECASE)
|
||||||
|
else:
|
||||||
regex_compile = regex.compile(ex, regex.MULTILINE)
|
regex_compile = regex.compile(ex, regex.MULTILINE)
|
||||||
|
|
||||||
if regex_compile is None:
|
if regex_compile is None:
|
||||||
|
|
Loading…
Reference in a new issue