fork download
  1. import re
  2.  
  3. LIST1=["AR BR_16_0138244", "AR # BR_16_0138254","AR BR_16_0138264, HHGG AR BR_16_0138264", "AR R_16_01382649" ,"AADSFG AR # R_16_01382679 AR # R_16_01382679" ]
  4.  
  5. pattern = r"(\bB?R_\w+)(?!.*\1)"
  6. for s in LIST1:
  7. m = re.search(pattern, s)
  8. if m:
  9. print(m.group(1))
  10.  
Success #stdin #stdout 0.03s 9556KB
stdin
Standard input is empty
stdout
BR_16_0138244
BR_16_0138254
BR_16_0138264
R_16_01382649
R_16_01382679