fork download
  1. import re
  2.  
  3. regex = r"^([^-()]+)(?:-[^()]*)?\([^()]*\)"
  4. s = ("TVTP-S2(xxxx123123)\n"
  5. "TVTP(xxxx123123)\n")
  6.  
  7. print(re.findall(regex, s, re.MULTILINE))
Success #stdin #stdout 0.02s 9540KB
stdin
Standard input is empty
stdout
['TVTP', 'TVTP']