This language bar is your friend. Select your favorite languages!

# Idiom #48 Multi-line string literal

Assign to variable s a string literal consisting in several lines of text

s = [[
Huey
Dewey
Louie
]]
char *s = "Huey\n"
"Dewey\n"
"Louie";
string s = @"Huey
Dewey
Louie";
auto s =  line1
line2
line3;

auto r = r" line1
line2
line3;
auto str = "One,
Two,
Three
";
var s = '''A
multi-line
string''';
s = """
multiline
heredoc
"""
s = "Spanning
string
works"
S = "Strings
may span
across multiple lines"
"and they can"
"have as many portions"
"as you want"
"all of them quoted".
s := Huey
Dewey
Louie
s = "several\n\
\lines\n\
\of\n\
\text\n"
let s = This is a very long string which needs
to wrap across multiple lines because
otherwise my code is unreadable.`;
let s = "This is a very long string which needs \
to wrap across multiple lines because \
otherwise my code is unreadable.";
let s = "This is a very long string which needs " +
"to wrap across multiple lines because " +
"otherwise my code is unreadable.";
$s = "This string is spanning three lines";$s = <<<EOD
Huey
Dewey
Louie
EOD;
var
_s: String;
begin
_s := 'one' + LineEnding + 'two' + LineEnding + 'three'
end.
$s = "Perl normally allows strings to contain newlines.";$s = q{
There are a good few ways to create multiline
text strings in perl.
};
\$s =<<EOSTR;
One of them is called the "here doc" (lifted from various UNIX shells).
A 'here doc' is the <<tag construct.  Perl continues to treat
all the text found as part of the string until there's a line containing
the EOSTR tag at the beginning
EOSTR
s = """Huey
Dewey
Louie"""
s = "Spanning
string
works"
let s = "line 1
line 2
line 3";
let s = r#"Huey
Dewey
Louie"#;

deleplace