import re aa = "1NoahEmma2LiamOlivia3MasonSophia4JacobIsabella5WilliamAva6EthanMia7MichaelEmily" result = re.findall(r'\d([A-Z][A-Za-z]+)([A-Z][A-Za-z]+)', aa) print(result)