fork download
  1. import re
  2.  
  3. pattern = r'(?:AB)+A'
  4. s = 'qqqqABqqqqqqABAqqqqqqABABABABAqqq'
  5. print(max(re.findall(pattern, s), key=len))
Success #stdin #stdout 0.03s 9400KB
stdin
Standard input is empty
stdout
ABABABABA