Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: multi-line Strings Date: Mon, 10 Dec 2012 13:36:46 -0800 Organization: A noiseless patient Spider Lines: 27 Message-ID: References: <7f36342c-2331-4484-874b-4a0f8953f160@googlegroups.com> <50c61150$0$293$14726298@news.sunsite.dk> <50c6413a$0$293$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 10 Dec 2012 21:36:49 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="61282af8d6595e8d991edb5ac03d6e00"; logging-data="3867"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18LzC75pK5GgmqjWJYWUqDz+0Ov19+9Wu4=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: Cancel-Lock: sha1:eFUe1oaQ9XsY6E9Kjv0i1DTXzbY= Xref: csiph.com comp.lang.java.programmer:20230 On 12/10/2012 1:22 PM, Eric Sosman wrote: > On 12/10/2012 3:08 PM, Arne Vajhøj wrote: >> [...] >> PS: And for those that do not know C#, then C# has "" strings >> with \ as escape like Java, but also has @"" string where >> \ is not an escape and where line change are allowed. > > As one of "those," and curious: Can a @"" string have an > embedded " character? > > @""Escapes? We don' need no steenkin' escapes!" he snarled." That's why I like triple quotes. Single and double embedded quotes are ok. In fact I'd provide an alternate syntax that harkened back to the Unix shell 'here document': String s = <<< ident """A string with "s in it.""" ident <<<; Now you can adapt the closing delimiter so it doesn't duplicate any substring portion of your constant. No escapes are ever required this way. Even triple quotes can be embedded arbitrarily.