How can I remove the string “\n” from within a Ruby string?

前端 未结 6 1054
迷失自我
迷失自我 2020-12-12 13:21

I have this string:

\"some text\\nandsomemore\"

I need to remove the \"\\n\" from it. I\'ve tried

\"some text\\nandsomemore         


        
6条回答
  •  自闭症患者
    2020-12-12 14:00

    use chomp or strip functions from Ruby:

    "abcd\n".chomp => "abcd"
    "abcd\n".strip => "abcd"
    

提交回复
热议问题