Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Daniele Futtorovic Newsgroups: comp.lang.java.programmer Subject: Re: Regexp exception in String.replaceAll Date: Wed, 26 Sep 2012 21:26:32 +0200 Organization: A noiseless patient Spider Lines: 24 Message-ID: References: <7ku568loa4ogik4e6asouundcbcjurg6lj@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Injection-Date: Wed, 26 Sep 2012 19:26:40 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="ab0f4a36851f1e27a3b9bb29e0bb4e7c"; logging-data="1346"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+n5GcR9XVRqhyMKR8ki3qX" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20 In-Reply-To: Cancel-Lock: sha1:dt9vQxu5sIwO9tGSnGIcUytSdAs= Xref: csiph.com comp.lang.java.programmer:18955 On 26/09/2012 19:00, markspace allegedly wrote: > On 9/26/2012 9:35 AM, Tim Slattery wrote: >> So before JSE6, if you needed String >> arguments, you had a choice of ReplaceAll or ReplaceFirst. Since I >> needed to allow for multiple occurrences of the replace string, I had >> to use ReplaceAll, and I missed this trap. (And I never considered >> that anybody would use a dollar sign in a filename!). Now that we're >> using JSE6, I can just change it to call replace instead of >> replaceAll. > > > Just to be a little pendantic here, I'm pretty sure that the "new" > String::replace just calls Pattern.quote before calling > String.replaceAll/First. Pattern.quote has been around since Java 1.5, > so it's not really new. > > To be a little pedantic myself and for the record, I don't think the quoting of a Pattern and the quoting of a replacement string are the same type of quoting. -- DF.