Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Joshua Cranmer Newsgroups: comp.lang.java.programmer Subject: Re: multi-line Strings Date: Tue, 11 Dec 2012 10:43:49 -0600 Organization: A noiseless patient Spider Lines: 25 Message-ID: References: <7f36342c-2331-4484-874b-4a0f8953f160@googlegroups.com> <50c61150$0$293$14726298@news.sunsite.dk> <50c6413a$0$293$14726298@news.sunsite.dk> <50c6598d$0$290$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 11 Dec 2012 16:43:57 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="5a9707252ba5efb9bece56d1f4656a90"; logging-data="9162"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+cCY6xwtbKIyds/psW+keKMflMXIMA/aA=" 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:CO6cY00ttQfCHPTJDl5xCNrrs48= Xref: csiph.com comp.lang.java.programmer:20252 On 12/10/2012 6:17 PM, Martin Gregorie wrote: > On Mon, 10 Dec 2012 18:04:33 -0500, Eric Sosman wrote: > > >> It's unfortunate that both Java and regex use \ so heavily, >> because it leads to a lot of escaping-of-escapes and harms readability. >> But why should it be a given that Java's literals should be different to >> avoid conflict with regex syntax? Why not change the regex syntax >> instead, and use, say, ~ for the role now taken by \? It might improve >> regexes to the point where they're merely unreadable, instead of >> intolerable. ;-) > > I've always liked the Awk and Perl default convention of delimiting > regexes with slashes: /regex/ - if their compilers can deal with this > cleanly, the Java compiler could surely do the same. Which works really well until you want to match the / character in pathnames. Or you want to lex but not parse the language--note that /foo/ is lexed as a regex if the preceding token is an operator and lexed as a sequence of tokens (DIV, IDENT, DIV) if the preceding token is an operator. -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth