【问题标题】:Problems with replacing into string替换成字符串的问题
【发布时间】:2011-07-08 19:58:00
【问题描述】:

我正在尝试执行这样的代码:

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

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

但它不起作用。我的错误是什么?

【问题讨论】:

    标签: ruby gsub


    【解决方案1】:

    你能描述一下它是如何不工作的吗?

    在 ruby​​ 1.9.2 中,我得到了我所期望的命令

    puts template
    

    给予

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

    【讨论】:

      猜你喜欢
      • 2010-10-04
      • 2015-10-11
      • 2011-11-24
      • 1970-01-01
      • 1970-01-01
      • 2020-03-15
      • 1970-01-01
      • 1970-01-01
      • 2012-02-15
      相关资源
      最近更新 更多