Jun-14-2018, 08:55 AM
How do I catch the 'not matched ones'?
Untangling the shorthand version is a bit of a struggle atm (still learning :) )
What am I doing wrong?
import re preset=r"cookie\." list1=['cookie.A001', 'cookie.H004', 'cookie.H004 andsomeothertext', 'cookie.ABC031', 'cookie.FAIL002'] list2=['A', 'H', 'ABC'] list2_pats = map(lambda x: re.compile(preset + r'(%s)([0-9]+)' % x), list2) #result = sum([pat.findall(item) for pat in list2_pats for item in list1], []) result =[] for item in list1: for pat in list2_pats: if item in pat: result.append(pat.findall(item)) else: result.append("eeew") output1, output2, output3 = zip(*result)Ideally I get another output (output3) which contains all the non-matches-inputs. Like "cookie.FAIL002".
Untangling the shorthand version is a bit of a struggle atm (still learning :) )
What am I doing wrong?