The Food Nerd
The Food Nerd

Reputation: 11

mysterious newline in google apps script string

can anyone tell me why this string:

var emailBody = "Thank you for submitting your request for an LWS ATP worksheet for the 2017-2018 school year."

Is rendering as:

Thank you for submitting your request for an LWS ATP worksheet for the

2017-2018 school year

Seriously, where is that newline coming from?

Thank you :)

Upvotes: 0

Views: 1219

Answers (1)

Suyash Gandhi
Suyash Gandhi

Reputation: 946

If you are fetching the string from the body of any email this kind of problem generally arises. The only way to get rid of the new line character is by using the following expression:

emailBody = emailBody.replace(/\n/gi," ");

if it still does not work then probably it will work by using "\r" instead of "\n" in the above given expression.

Upvotes: 2

Related Questions