fork download
  1. import re
  2. pattern = re.compile(r"^\w+(?: (?!feat\b)\w+)?")
  3.  
  4. def cut(text):
  5. m = pattern.search(text)
  6. if m:
  7. return m.group(0)
  8. return string
  9.  
  10. print(cut("Technotronic feat Ya Kid K"))
  11. print(cut("Technotronic feature Ya Kid K"))
Success #stdin #stdout 0.02s 9464KB
stdin
Standard input is empty
stdout
Technotronic
Technotronic feature