我是谷歌應用程序腳本的新手。
我試圖使用此問題中的參考將 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;
}
雖然我的實際期望在第三列。
有人能告訴我我以前的腳本有什麼問題嗎?
謝謝!
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句