在字符串中为特定单词添加引号

时间:2016-03-09 08:36:50

标签: ruby string double-quotes

我有一个字符串,其值必须在引号中。以下是我目前的文字:

text = "#{value1} has viewed your #{value2}"

我希望value2在引号中。我想要:

text = ""#{value1} has viewed your "#{value2}""

我该如何实现?任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:5)

func mapView(mapView: GMSMapView, didTapOverlay overlay: GMSOverlay) {
    /* Here we cast the GMSOverlay to be a GMSPolygon */
    let overlay = overlay as! GMSPolygon

    overlay.fillColor = UIColor.whiteColor()

    /* Now the color of the polygon has changed on the map */
}

甚至:

text = %Q|#{value1} has viewed your "#{value2}"|
text = "#{value1} has viewed your \"#{value2}\""

More info