fork download
  1. import re
  2. rx = re.compile(r"/(?:[^/\s]*/)*\w+")
  3. texts = ["/this/is//an example of what I want /to///do", "/this/is//an example of what i want to /do"]
  4. for text in texts:
  5. print( rx.sub('', text).strip() )
  6.  
Success #stdin #stdout 0.03s 9616KB
stdin
Standard input is empty
stdout
example of what I want
example of what i want to