fork download
  1. # your code goes here
  2.  
  3.  
  4.  
  5.  
  6. import re
  7. string = '\\\\r \\\\nLove the filtered water \rand crushed ice in the door.'
  8. new_string = re.sub(r"\\[rtnfv]|\[tnrfv]"," ",string)
  9.  
  10. print(new_string)
  11. # if i use print(), \r is erased. however, the actual value of new_string is as below.
  12. #>> '\\ \\ Love the filtered water \rand crushed ice in the door.'
  13. # we still can see '\rand'.
  14. # so i'm gonna stick with using re.sub(r"[\t\n\r\f\v]"," ",string) style!rather than re.sub(r"\\[rtnfv]|\[tnrfv]"," ",string)
  15. # because this code has no problem. but i was just curious why re.sub(r"[\t\n\r\f\v]"," ",string) style doesn't work.. seems like it should work
  16. # thanks for your explanation sir! as a newbie.. this is really helpful :)
Success #stdin #stdout 0.01s 7248KB
stdin
Standard input is empty
stdout
\  \ Love the filtered water 
and crushed ice in the door.