I have two text files that I have turned into lists. List1 has lines that look like this:
'U|blah|USAA032812134||blah|blah|25|USAA032812134|blah|A||4||blah|2019-05-28 12:54:59|blah|123456||blah'
list2 has lines that look like this:
['smuspid\n', 'USAA032367605\n', 'USAA032367776\n', 'USAA044754265\n', 'USAA044754267\n']
I want to return every line in list1 that has a match in list2. I've tried using regex for this:
found = []
check = re.compile('|'.join(list2))
for elem in list1:
if check.match(elem):
found.append(elem)
but my code above is returning an empty list. Any suggestions?
matchor exact equal