commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@gmail.com>
Subject Re: svn commit: r1407141 - /commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
Date Fri, 09 Nov 2012 16:45:46 GMT
Committed revision 1407536.



On Fri, Nov 9, 2012 at 9:51 AM, Matt Benson <gudnabrsam@gmail.com> wrote:

>
> On Fri, Nov 9, 2012 at 1:53 AM, Jörg Schaible <Joerg.Schaible@scalaris.com
> > wrote:
>
>> Hi Greg,
>>
>> the pattern matches (also) a single space that gets replaced by a single
>> space. Therefor are most of the actual performed replacements completely
>> superfluous, since I expect this to be the common case. The pattern should
>> be something along "[\\s&&[^ ]]\\s*".
>>
>>
> That seems to say "a whitespace character that is not a space, optionally
> followed by any number of whitespace characters."  Wouldn't this
> necessarily preclude any block of whitespace that *does* begin with a
> space?  This does seem to be on the right track, however.  What about:
>
> "(?: \\s|[\\s&&[^ ]])\\s*"
>
> This seems to do the right thing:  beginning with a non-capturing group
> that matches { EITHER a space followed by a whitespace character OR a
> whitespace character that is not a space }, optionally followed by any
> number of whitespace characters.
>
> Matt
>
>
>> - Jörg
>>
>> ---------------
>>
>> Betreff: svn commit: r1407141 -
>>
>> /commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
>> Absender: ggregory-1oDqGaOF3Lkdnm+yROfE0A@public.gmane.org
>> Datum: Thu, 08 Nov 2012 15:54:25 +0000
>> Newsgruppe: gmane.comp.jakarta.commons.scm
>>
>> Author: ggregory
>> Date: Thu Nov  8 15:54:25 2012
>> New Revision: 1407141
>>
>> URL: http://svn.apache.org/viewvc?rev=1407141&view=rev
>> Log:
>> Rename private WHITESPACE_BLOCK to WHITESPACE_PATTERN.
>>
>> Modified:
>>
>> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
>>
>> Modified:
>>
>> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
>> URL:
>>
>> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java?rev=1407141&r1=1407140&r2=1407141&view=diff
>>
>> ==============================================================================
>> ---
>>
>> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
>> (original)
>> +++
>>
>> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
>> Thu Nov  8 15:54:25 2012
>> @@ -144,7 +144,7 @@ public class StringUtils {
>>      /**
>>       * A regex pattern for recognizing blocks of whitespace characters.
>>       */
>> -    private static final Pattern WHITESPACE_BLOCK =
>> Pattern.compile("\\s+");
>> +    private static final Pattern WHITESPACE_PATTERN =
>> Pattern.compile("\\s+");
>>
>>      /**
>>       * <p>{@code StringUtils} instances should NOT be constructed in
>> @@ -6472,7 +6472,7 @@ public class StringUtils {
>>          if (str == null) {
>>              return null;
>>          }
>> -        return WHITESPACE_BLOCK.matcher(trim(str)).replaceAll(" ");
>> +        return WHITESPACE_PATTERN.matcher(trim(str)).replaceAll(" ");
>>      }
>>
>>      /**
>>
>>
>> ---------------
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message