0
我在爲我的項目使用ruby 1.9.1。 所以我需要從字符串中刪除一些評論。 如:#encoding:utf-8在軌道上不工作ruby
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:RelyOnVML/>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]-->
所以我寫一個函數來text.gsub(/<!--(.*?)-->/s, "")
刪除它在幫助和頂部的輔助文件,添加RB # encoding: utf-8
,也定義在application.rb中config.encoding = "utf-8"
但它似乎並沒有爲我工作。 我得到的錯誤
ActionView::Template::Error (incompatible encoding regexp match (Windows-31J regexp with UTF-8 string))
在這種情況下你有任何支持嗎?謝謝!
試試這個'text.gsub(/ /m,「」)' – 2014-11-23 03:22:47
@AvinashRaj感謝您的支持。它現在有效。 – 2014-11-23 07:10:03