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+"
  6. result = []
  7. for s in LIST1:
  8. result += re.findall(pattern, s)
  9.  
  10. print(list(set(result)))
Success #stdin #stdout 0.02s 9560KB
stdin
Standard input is empty
stdout
['R_16_01382649', 'R_16_01382679', 'BR_16_0138254', 'BR_16_0138244', 'BR_16_0138264']