regex scanner groups findall tuple bug fixed
This commit is contained in:
parent
097c60a7bc
commit
950ed8fde9
@ -320,7 +320,8 @@ class Test_Regex(unittest.TestCase):
|
|||||||
# sample inputs for checking the outcomes of good inputs / test_basic_regex
|
# sample inputs for checking the outcomes of good inputs / test_basic_regex
|
||||||
self.good_inputs_list = [
|
self.good_inputs_list = [
|
||||||
"-RP '\\b\\d{3}\\b' -RPl threedigits",
|
"-RP '\\b\\d{3}\\b' -RPl threedigits",
|
||||||
"-RP 'TestCase' -RP 'page' -RPl testcases -RPl page_word",
|
#"-RP 'TestCase' -RP 'page' -RPl testcases -RPl page_word",
|
||||||
|
"-RP '(\\b[a-zA-Z]{3}\\b)' -RPl 3LETTERS -RP '(\\b(1[\d+])|(2[\d+])\\b)' -RPl NUMBERS",
|
||||||
"-CP 'Chevalier' -CPl chev_com -RP 'welcome to Wikipedia' -RPl wiki_welcome -CP 'Warning' -CPl warning",
|
"-CP 'Chevalier' -CPl chev_com -RP 'welcome to Wikipedia' -RPl wiki_welcome -CP 'Warning' -CPl warning",
|
||||||
"-CP 'WP:EVADE' -CPl wp_evade"
|
"-CP 'WP:EVADE' -CPl wp_evade"
|
||||||
]
|
]
|
||||||
|
12
wikiq
12
wikiq
@ -189,7 +189,17 @@ class RegexPair(object):
|
|||||||
#given that there are matches to be made
|
#given that there are matches to be made
|
||||||
if self.pattern.search(content) is not None:
|
if self.pattern.search(content) is not None:
|
||||||
m = self.pattern.findall(content)
|
m = self.pattern.findall(content)
|
||||||
temp_dict[self.label] = ', '.join(m)
|
m_fixed = []
|
||||||
|
for match in m:
|
||||||
|
if type(match) is tuple:
|
||||||
|
matchies = set()
|
||||||
|
for sub_m in match:
|
||||||
|
matchies.add(sub_m)
|
||||||
|
m_fixed += matchies
|
||||||
|
else:
|
||||||
|
m_fixed.append(match)
|
||||||
|
|
||||||
|
temp_dict[self.label] = ', '.join(m_fixed)
|
||||||
else:
|
else:
|
||||||
temp_dict[self.label] = None
|
temp_dict[self.label] = None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user