Hi Matt, Matt Benson wrote:
> On Fri, Nov 9, 2012 at 1:53 AM, Jörg Schaible > <joerg.schai...@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-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org