I have a of regex patterns all of which I want to find in string and store the found pattern. I need all the possible matches of the regex in the given list, something like below.
regex = ["([a-zA-Z])*-([0-9])*","([0-9])*-([a-zA-Z]*)"]
s = 'This 24-hour journey is such a burden just get my I-20'
reg = re.compile('|'.join(regex))
arr = re.findall(reg,s)
print(arr)
But this gives me an output which is really weird. What I need as output is the list ['24-hour','I-20']. But what I am getting is this.
[('', '', '4', 'h'), ('I', '0', '', '')]
I think I am using the findall function badly but don't know how. Please help!