Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: Roedy Green Newsgroups: comp.lang.java.programmer Subject: Re: Confusion about String.matches method Date: Mon, 06 Jun 2011 00:50:18 -0700 Organization: Canadian Mind Products Lines: 30 Message-ID: References: <50016a00-9422-46d4-8278-619fedafff55@c41g2000yqm.googlegroups.com> <2fd869d6-c2f6-4360-85b4-6df2b6e68fb0@p13g2000yqh.googlegroups.com> <94n2jpFa1oU1@mid.individual.net> Reply-To: Roedy Green NNTP-Posting-Host: RCd/Ul4tyxGUBII8WGwa5g.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: Forte Agent 6.00/32.1186 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5004 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. If you are trying to match a eol char in a regex the two chars in ram will 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. -- Roedy Green Canadian Mind Products http://mindprod.com How long did it take after the car was invented before owners understood cars would not work unless you regularly changed the oil and the tires? We have gone 33 years and still it is rare to uncover a user who understands computers don't work without regular backups.