import rec = re.compile('.*?(\w+\d+).*?(\w+.*?\d+.*?\w+)')c1 = re.findall(c, text)print(c1[0][0])print(c1[0][1])