Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Daniele Futtorovic Newsgroups: comp.lang.java.programmer Subject: Re: Confusion about String.matches method Date: Wed, 01 Jun 2011 18:59:23 +0200 Organization: A noiseless patient Spider Lines: 17 Message-ID: References: <50016a00-9422-46d4-8278-619fedafff55@c41g2000yqm.googlegroups.com> <2fd869d6-c2f6-4360-85b4-6df2b6e68fb0@p13g2000yqh.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 1 Jun 2011 16:59:22 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="F519hiVipveSa9xSGS6oxw"; logging-data="11009"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19krDzv0i6Y8nMzVszMyTVM" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 In-Reply-To: Cancel-Lock: sha1:AtvNMsJUbPPwctUH6AMvuqHAt5Q= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:4862 On 01/06/2011 17:17, Joshua Cranmer allegedly wrote: > On 06/01/2011 10:10 AM, laredotornado wrote: >> which returns false. If I remove the new line ("\n"), it matches, but >> I can't guarantee my input won't contain new lines. How can I modify >> my regular expression to match? Thanks, - Dave > > There is a flag that you can set to treat newlines as regular characters. > Pattern.DOTALL, to be precise. You can't use that in combination with String#matches() however, as it is an argument to Pattern#compile. So either go that way, or use the embedded flag, "(?s)" (put it at the start of your regex). -- DF. Determinism trumps correctness.