commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörg Schaible <joerg.schai...@gmx.de>
Subject Re: svn commit: r1407141 - /commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
Date Fri, 09 Nov 2012 21:05:30 GMT
Hi Matt,

Matt Benson 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."

Right.

> Wouldn't this
> necessarily preclude any block of whitespace that *does* begin with a
> space? 

Fine in the context where the pattern is actually used, since the matching 
string is trimmed first.

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

IMHO the capturing group is not necessary here.

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message