fork(1) download
  1. import re
  2. ss = ['(2)2(6)2(6)2(2)2(8)', '(G)8(8)(G)4(C)(G)8(8)']
  3. r = r'(?=((?:\([A-Z0-9]+\)|\d){2,}).*\1)'
  4. for s in ss:
  5. print(s)
  6. print(re.findall(r, s)) #print([x.group(1) for x in re.finditer(r, s)])
  7. print("---------")
Success #stdin #stdout 0s 9024KB
stdin
Standard input is empty
stdout
(2)2(6)2(6)2(2)2(8)
['(2)2', '2(6)', '(6)2']
---------
(G)8(8)(G)4(C)(G)8(8)
['(G)8(8)', '8(8)']
---------