开发者

Problems with replacing into string

开发者 https://www.devze.com 2023-03-18 20:41 出处:网络
I\'m trying to execute code like this: template = \" ... here html tags [sitename] ... here html tags \" template = template.gsub(/\\[sitename\\]/,\"http://google.com\")

I'm trying to execute code like this:

template = "
... here html tags
[sitename]
... here html tags
"

template = template.gsub(/\[sitename\]/,"http://google.com")

But it's not working. What is my mista开发者_高级运维ke?


Can you describe how it's not working?

In ruby 1.9.2 I get what I expected, the command

puts template

gives

... here html tags
http://google.com
... here html tags
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号