import re
def extraction(parentTag):
should_retain = True
for imageTag in parentTag:
if re.search("^(\d+.+\d)",imageTag) and not re.search("^(\d+.+\d[-^]\w)",imageTag) and not re.search("^(\d+.+\d[-^]\d)",imageTag):
should_retain = False
break
if should_retain:
return parentTag
return None
expected_input = [
['419adf7', '1.0.22-SNAPSSHOT'],
['1.0.24', '82e13c1', 'master'],
['1.0.25-1618314650'],
['1.0.10', '7ad4886'],
['1.0.13-1589279873', 'e597811'],
['73a3788'],
]
expected_input = list(filter(None,list(map(extraction, expected_input))))
print(expected_input)
Current Output = [['1.0.25-1618314650'], ['1.0.13-1589279873', 'e597811']]
Expected Output = [['1.0.25-1618314650'], ['1.0.13-1589279873', 'e597811'], ['419adf7', '1.0.22-SNAPSSHOT'], ['73a3788']]
And also is there any better way to write the code to get the Expected Output using regex.