fork download
  1. import re
  2. LIST1=["AR BR_18_0138249", "AR R_16_01382649", "BR 16 0138264", "R 16 01382679" ]
  3. pattern = r"\b(B?R(?=([\s_]))(?:\2\d+)+)\b(?!.*\b\1\b)"
  4. for i in LIST1:
  5. rest = re.search(pattern, i)
  6. if rest:
  7. print(rest.group(1))
Success #stdin #stdout 0.02s 9720KB
stdin
Standard input is empty
stdout
BR_18_0138249
R_16_01382649
BR 16 0138264
R 16 01382679