【发布时间】:2021-11-01 04:49:36
【问题描述】:
我是谷歌应用脚本的新手。
我试图在这个问题中使用 reference 在谷歌应用脚本中将 html 字符串转换为没有 html 标签的纯文本。
但是,当我尝试将它应用到我的脚本时,它没有按预期工作。
这是我使用的脚本:
function toStringFromHtml(html)
{
html = '<div>' + html + '</div>';
html = html.replace(/<br>/g,"");
var document = XmlService.parse(html);
var strText = XmlService.getPrettyFormat().format(document);
strText = strText.replace(/<[^>]*>/g,"");
return strText;
}
而我的实际期望在第三列。
谁能告诉我我之前的脚本有什么问题?
谢谢!
【问题讨论】:
标签: javascript html google-apps-script google-sheets