【问题标题】:Apps Srcipt indexOf() not working properlyApps 脚本 indexOf() 无法正常工作
【发布时间】: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


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-06
    • 2014-12-07
    • 2015-04-04
    • 1970-01-01
    • 2017-04-08
    • 2015-07-27
    • 2011-06-13
    • 1970-01-01
    相关资源
    最近更新 更多