Javascript 应用程序Srcipt indexOf()工作不正常

Javascript 应用程序Srcipt indexOf()工作不正常,javascript,google-apps-script,indexof,Javascript,Google Apps Script,Indexof,我正在读电子邮件的正文。您可以检查身体在所附照片中的外观 我想得到以下子字符串:“Current status-ROB2ReOnb”。我注意到,当我要查找的文本不在同一行时,indexOf会给我“-1”。但是,当在同一行时,我可以得到indexOf的正值 我的代码如下: current\u status=body.substring(body.indexOf(“当前状态-”),body.indexOf(“应用程序激活”) 你知道我做错了什么吗?我一直在努力找出错误。任何提示/线索都是受欢迎的 我

我正在读电子邮件的正文。您可以检查身体在所附照片中的外观

我想得到以下子字符串:“Current status-ROB2ReOnb”。我注意到,当我要查找的文本不在同一行时,indexOf会给我“-1”。但是,当在同一行时,我可以得到indexOf的正值

我的代码如下:

current\u status=body.substring(body.indexOf(“当前状态-”),body.indexOf(“应用程序激活”)

你知道我做错了什么吗?我一直在努力找出错误。任何提示/线索都是受欢迎的


我通过@Nick Parsons的评论得到了答案:

help = HtmlService.createHtmlOutput('Active\nwith');
current_status_aux = body.substring(body.indexOf("Current status -"),body.indexOf(help))

“Active”和“with”可能会用换行符分隔吗?
\n
非常感谢@Nick!我使用了以下代码,它成功了:
help=HtmlService.createHtmlOutput('Active\nwith');current\u status\u aux=body.substring(body.indexOf(“current status”)、body.indexOf(help))