With Python, you can do the following:
p="((?P<two_chars>[A-Z]{2})(?P=two_chars))"
s="AZAZABCDCUCUPIPI"
re.findall(p, s)
[('AZAZ', 'AZ'), ('CUCU', 'CU'), ('PIPI', 'PI')]
and then extract the items you want from the list. Or you can be faster and do:
[k for k,v in re.findall(p,s)]
['AZAZ', 'CUCU', 'PIPI']
Hope this helps.
source
share