简体   繁体   中英

Having issues with Google Apps Script replaceText regex

So in my code

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

works and so do simple regexs, but I can't get more complex ones to work. For example I want to remove all spacing between two tags and replace it with three carriage returns. I've tested it out in regexr and other tools and it works but it does nothing in my Apps Script.

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

this doesn't work either

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

我尝试了这个,对我有用

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM