user14491665
user14491665

Reputation: 45

Apps Srcipt indexOf() not working properly

I am reading the body text of emails. You can check how the body appears in the photo attached.

I want to get the following substring: 'Current status- ROB2ReOnb". I am noticing that when the text I am looking for, is not on the same row, the indexOf gives me "-1". However, when is on the same row I can get a positive value for the indexOf.

My code is the following:

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

Do you know what can I be doing wrong? I am trying to spot the error for so long. Any tip/clue is more than welcome.

![enter image description here

Upvotes: 0

Views: 58

Answers (1)

user14491665
user14491665

Reputation: 45

I got the answer with @Nick Parsons comment:

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

Upvotes: 1

Related Questions