I´m trying to create a multiline string in Google Apps Scrtip, something like this in Javascript:
var temp = \`Hello
World!\`;
I have a text that I want to analyze but I don't want to pre-process it.
Is it possible?
If, for example, you had a real long string that extended out past the right margin in the code editor, and you wanted to put it on multiple lines in the editor so that you don't need to scroll to the right to read it, but still want the string to be analyzed as one long string, then you can use:
var a = 'some text\
more text here\
third line.';
The above text in the variable a
will print as one line.
If you are using V8, then you can use commas at the end of each line.
var a = 'some text,
more text here,
third line.';
If you want to cause the string to wrap, in something like an email, or a dialog box, you can use the non-printing newline control characters \n
var t = 'first line \nsecond line \nthird line';
The above string in the variable t
will print on three lines.
Note that I did not put any space after \n
or the next line would start with a space.
If you are using HTML, then you can use <br>
It's now possible to use the V8 runtime for google scripts.
This allows you to use the javascript multi-line strings in your google scripts.
Here's how to enable the V8 runtime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With