Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Nigel Wade Newsgroups: comp.lang.java.programmer Subject: Re: Confusion about String.matches method Date: Mon, 06 Jun 2011 12:15:08 +0100 Lines: 43 Message-ID: <953r5tFbonU1@mid.individual.net> References: <50016a00-9422-46d4-8278-619fedafff55@c41g2000yqm.googlegroups.com> <2fd869d6-c2f6-4360-85b4-6df2b6e68fb0@p13g2000yqh.googlegroups.com> <94n2jpFa1oU1@mid.individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: individual.net o/AK/bnSNGM8nenALXsIQwFQ++TTswyjJMwV10hn7iXIqq3Jvv Cancel-Lock: sha1:B3P/a53Wy7BEBmCmc3k4BTCxUNY= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.1.16) Gecko/20101125 SUSE/3.0.11 Thunderbird/3.0.11 In-Reply-To: Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5013 On 06/06/11 08:50, Roedy Green wrote: > On Wed, 01 Jun 2011 16:02:16 +0100, Nigel Wade > wrote, quoted or indirectly quoted someone who said : > >> So, to get your '\\n' in the RE you need to >> have '\\\\n' in the string. > > Oops. Oops yourself. > > If you are trying to match a eol char in a regex the two chars in ram > will be \ n If they are, you won't match a newline. The '\' needs to be escaped in the RE. The string in the RE needs to be \\n. > > If you are creating a string literal it will be "\\n" > > The extra \ is to tell Java this is not a Java literal. > > The easy way to create these strings is to use Quoter. > See http://mindprod.com/applet/quoter.html > > One you get the hang of it, you can write them off the top of your > head. > and, apparently, get them wrong. I repeat what I said in my previous post: Anyone who claims they understand RE is just someone who hasn't yet realized they don't. -- Nigel Wade