簡體   English   中英

應用程序的 indexOf() 無法正常工作

[英]Apps Srcipt indexOf() not working properly

我正在閱讀電子郵件的正文。 您可以檢查身體在所附照片中的顯示方式。

我想獲得以下 substring:“當前狀態- ROB2ReOnb”。我注意到當我要查找的文本不在同一行時,indexOf 給我“-1”。但是,當在同一行時行我可以得到 indexOf 的正值。

我的代碼如下:

current_status = body.substring(body.indexOf("Current status -"),body.indexOf("Active with App"))

你知道我做錯了什么嗎? 我試圖發現錯誤這么久。 任何提示/線索都非常受歡迎。

![在此處輸入圖像描述

我得到了@Nick Parsons 評論的答案:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM