Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #5010

Re: Confusion about String.matches method

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!goblin3!goblin.stu.neva.ru!exi-transit.telstra.net!news.telstra.net!exi-spool.telstra.net!exi-reader.telstra.net!not-for-mail
Date Mon, 06 Jun 2011 20:18:24 +1000
From Esmond Pitt <esmond.pitt@bigpond.com>
Reply-To not.esmond.pitt@not.bigpond.com
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10
MIME-Version 1.0
Newsgroups comp.lang.java.programmer
Subject Re: Confusion about String.matches method
References <baaf3c9c-b3be-4d14-a5de-2149617640b2@k17g2000vbn.googlegroups.com> <slrniua9ad.phi.avl@gamma.logic.tuwien.ac.at> <50016a00-9422-46d4-8278-619fedafff55@c41g2000yqm.googlegroups.com> <nqrau6pa3u55q5ilki6h2dqk3qprd3er9d@4ax.com> <2fd869d6-c2f6-4360-85b4-6df2b6e68fb0@p13g2000yqh.googlegroups.com> <94n2jpFa1oU1@mid.individual.net> <ig1pu6dqcs402grnpe9kpa92lit9ts7os9@4ax.com>
In-Reply-To <ig1pu6dqcs402grnpe9kpa92lit9ts7os9@4ax.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Lines 27
Message-ID <4deca972$0$12380$c30e37c6@exi-reader.telstra.net> (permalink)
NNTP-Posting-Host 120.151.14.51
X-Trace 1307355506 exi-reader.telstra.net 12380 120.151.14.51:32778
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5010

Show key headers only | View raw


On 6/06/2011 5:50 PM, Roedy Green wrote:
> On Wed, 01 Jun 2011 16:02:16 +0100, Nigel Wade<nmw-news@ion.le.ac.uk>
> 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.

No 'oops' about it. The poster is correct.

> 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"

And if you are creating a regex it will be "\\\\n".

> The extra \ is to tell Java this is not a Java literal.

And the doubled \\ are there to tell the regex this is a backslashed 
backslash, i.e. a real backslash, not a regex escape.

> The easy way to create these strings is to use Quoter.

I don't see how any piece of software can understand whether a quoted 
string is for use in a regular expression or not.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Confusion about String.matches method laredotornado <laredotornado@zipmail.com> - 2011-05-31 10:24 -0700
  Re: Confusion about String.matches method Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-05-31 17:28 +0000
    Re: Confusion about String.matches method laredotornado <laredotornado@zipmail.com> - 2011-05-31 13:15 -0700
      Re: Confusion about String.matches method Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-05-31 23:10 +0200
      Re: Confusion about String.matches method Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-05-31 21:26 +0000
      Re: Confusion about String.matches method Ian Shef <invalid@avoiding.spam> - 2011-05-31 22:20 +0000
      Re: Confusion about String.matches method Roedy Green <see_website@mindprod.com.invalid> - 2011-05-31 15:53 -0700
        Re: Confusion about String.matches method laredotornado <laredotornado@zipmail.com> - 2011-06-01 07:10 -0700
          Re: Confusion about String.matches method Nigel Wade <nmw-news@ion.le.ac.uk> - 2011-06-01 16:02 +0100
            Re: Confusion about String.matches method Roedy Green <see_website@mindprod.com.invalid> - 2011-06-06 00:50 -0700
              Re: Confusion about String.matches method Esmond Pitt <esmond.pitt@bigpond.com> - 2011-06-06 20:18 +1000
                Re: Confusion about String.matches method Roedy Green <see_website@mindprod.com.invalid> - 2011-06-07 21:15 -0700
                Re: Confusion about String.matches method Michael Wojcik <mwojcik@newsguy.com> - 2011-06-08 11:13 -0400
                Re: Confusion about String.matches method Esmond Pitt <esmond.pitt@bigpond.com> - 2011-06-09 19:19 +1000
                Re: Confusion about String.matches method Roedy Green <see_website@mindprod.com.invalid> - 2011-06-07 21:18 -0700
                Re: Confusion about String.matches method Gene Wirchenko <genew@ocis.net> - 2011-06-08 07:50 -0700
              Re: Confusion about String.matches method Nigel Wade <nmw-news@ion.le.ac.uk> - 2011-06-06 12:15 +0100
          Re: Confusion about String.matches method Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-01 11:17 -0400
            Re: Confusion about String.matches method Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-06-01 18:59 +0200
          Re: Confusion about String.matches method Ian Shef <invalid@avoiding.spam> - 2011-06-01 19:41 +0000
      Re: Confusion about String.matches method Jim Janney <jjanney@shell.xmission.com> - 2011-06-01 08:41 -0600

csiph-web