fork download
  1. from functools import partial
  2. import re
  3.  
  4. _clean = partial(re.compile(r' +').sub, ' ')
  5.  
  6. def strip_all(s, subs=(), clean=True):
  7. s = re.sub(r'|'.join(map(re.escape, subs)), '', s)
  8. if clean:
  9. s = _clean(s).strip()
  10. return s
  11.  
  12. text = "pidor blya, ya tibe pokushati prines"
  13. print strip_all(text, "pidoryahuilo")
Success #stdin #stdout 0.01s 7896KB
stdin
Standard input is empty
stdout
b, tbe kst nes