【问题标题】:Having issues with Google Apps Script replaceText regexGoogle Apps 脚本 replaceText 正则表达式有问题
【发布时间】:2015-04-11 01:37:47
【问题描述】:

所以在我的代码中

body.replaceText("test1","test2");

工作,简单的正则表达式也是如此,但我无法让更复杂的正则表达式工作。例如,我想删除两个标签之间的所有间距并将其替换为三个回车符。我已经在 regexr 和其他工具中对其进行了测试,它可以工作,但在我的 Apps 脚本中没有任何作用。

 body.replaceText("/</em>[\r\n]+<strong>/g","</em>\r\r\r<strong>");

这也不行

body.replaceText("</em>[\r\n]+<strong>","</em>\r\r\r<strong>");

【问题讨论】:

    标签: regex google-apps-script


    【解决方案1】:

    我试过了,它对我有用

    body.replaceText("</em>\\[\\\\r\\\\n\\]\\+<strong>", '</em>\r\r\r<strong>');
    

    【讨论】:

    猜你喜欢
    • 2017-07-16
    • 2013-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多