Skip to content

Commit 2adb143

Browse files
author
joseramon.afonso
committed
Fixed parser regex when group != 0
1 parent b93ede6 commit 2adb143

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

devoutils/sorter/parser.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ def parser_regex(regex, group, ignorecase=False):
3636
:param ignorecase: False by default
3737
:return: the group obtained.
3838
"""
39-
if ignorecase:
40-
return lambda x: re.search(regex, x, re.I).groups()[group]
41-
return lambda x: re.search(regex, x).groups()[group]
39+
if group == 0:
40+
if ignorecase:
41+
return lambda x: re.search(regex, x, re.I).groups()[group]
42+
return lambda x: re.search(regex, x).groups()[group]
43+
else:
44+
if ignorecase:
45+
return lambda x: re.findall(regex, x, re.I)[group]
46+
return lambda x: re.findall(regex, x)[group]

0 commit comments

Comments
 (0)