Let's assume I have two list of strings as follows.
lst_1 = ['foo','bar','Invoice No: SME2324-AA']
lst_2 = ['trincas','hotel park','delivery date 12-sept-2019','invoice no: 11245']
Objective: I want to extract the invoice number from these two lists.
My Approach so far:
lst_3 = [lst_1,lst_2]
txt=[]
for inv_no in lst_3:
for i in inv_no:
z = i
inv = re.search(r'Invoice (\S+) (.+?)',' '.join(z))
txt.append(inv)
When I wanted to see the output i.e. txtI am getting as
[None, None, None, None, None, None, None, None]
What I am looking for is
['SME2324-AA','11245']
What I am missing out here? Any help would be appreciated.
z=iand' '.join(z)? why not justinv = re.search(r'Invoice (\S+) (.+?)', i)? That will get you closer to a solutionl3 = [*l1, *l2]