【发布时间】:2018-07-03 07:59:26
【问题描述】:
txt = "I'm happy :)" #This is input from user
txt = txt.gsub("'","\\'")
raise :test
我得到“我很高兴 :)m 很高兴 :)”
我想得到这个字符串变量的值是“I\'m happy :)”(带一个反斜杠)
我正在使用 Rails。我将使用这个字符串变量来参数这种情况我不能使用“puts”方法。我尝试了很多方法(%W(...), %(...)) 来解决,但我还是解决不了。
【问题讨论】:
标签: ruby-on-rails ruby