Change useless tr to gsub

ref https://github.com/rails/rails/commit/588f267e71083928ee8b6375a444fb674dad8fcf#commitcomment-2746016