Reputation: 13
In google sheets i have merged 4 cells into 1 and then i put the entered text data of that cell into an array position. When i call that array position and try to place it into an email body, i get 3 extra commas on the end of the string.
How can i remove the commas or merge the data into 1 item?
My merged cell string text is in position 15. When i drop that data into the email, it will say: Data is here,,,
I tried slice, join & replace, but none of them worked.
var incidentsum = data[15];
var newincident = incidentsum.slice(0, incidentsum.length - 3);
var newincident = incidentsum.join(" ");
incidentsum.replace(/,/g, "")
Any ideas?
Upvotes: 0
Views: 148
Reputation: 7268
You can use replace
with a regex ($ means end of the line):
var incidentsum = data[15]; //Data is here,,,
var newincident = incidentsum.replace(/,,,$/, ''); //Data is here
Upvotes: 1