【发布时间】:2021-03-19 13:26:02
【问题描述】:
我正在阅读电子邮件的正文。您可以检查身体在所附照片中的显示方式。
我想获取以下子字符串:'Current status-ROB2ReOnb"。我注意到当我要查找的文本不在同一行时,indexOf 给了我“-1”。但是,什么时候在同一行上,我可以得到 indexOf 的正值。
我的代码如下:
current_status = body.substring(body.indexOf("Current status -"),body.indexOf("Active with App"))
你知道我做错了什么吗?我试图发现错误这么久。任何提示/线索都非常受欢迎。
【问题讨论】:
-
可以用换行符分隔“Active”和“with”吗?
\n -
非常感谢@Nick!我使用了以下代码,它工作:
help = HtmlService.createHtmlOutput('Active\nwith'); current_status_aux = body.substring(body.indexOf("Current status"),body.indexOf(help))
标签: javascript google-apps-script indexof