Remove double quotes from string

前端 未结 4 1311
不思量自难忘°
不思量自难忘° 2021-01-01 19:20

I\'m trying to grab data from a MySQL database and use Ruby to reformat it into a flat text file. Some of my MySQL data contains double quotes like so:

<
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-01 19:58

    You could use something like:

    text = 'Matthew "Matt" Perry'
    
    text.tr(%q{"'}, '|') # => "Matthew |Matt| Perry"
    
    text = "Matthew 'Matt' Perry"
    text.tr(%q{"'}, '|') # => "Matthew |Matt| Perry"
    

提交回复
热议问题