-4
内容文件我想更换一些文字用空格和空格在红宝石中的所有文件。替换红宝石
toReplace = [
'<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"pl\" xml:lang=\"pl\">
<head>'
]
replacement = [
'<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">'
]
我为此使用gsub,但它不起作用,因为空白和空格有问题。
contents.gsub! toReplace[i], replacement[i]
我该怎么做?
它看起来像你正在尝试做一个转换为HTML5。如果你看到http://www.w3schools.com/html/html5_migration.asp – zhon
您可以考虑使用[引入nokogiri(https://github.com/sparklemotion/nokogiri)解析您的网页,并为您的outputing新的HTML页。 – zhon
请阅读“[问]”,包括链接的页面和“[mcve]”。我们希望看到两个以上的数组分配。你有什么尝试?如果你不是为什么不呢?目前看起来您要求我们为您编写代码。 –