explain whitespace pattern

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1407537 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Matthew Jason Benson 2012-11-09 16:50:39 +00:00
parent fa4ed70023
commit 8a946932c8
1 changed files with 5 additions and 0 deletions

View File

@ -150,6 +150,11 @@ public class StringUtils {
/**
* A regex pattern for recognizing blocks of whitespace characters.
* The apparent convolutedness of the pattern serves the purpose of
* ignoring "blocks" consisting of only a single space: the pattern
* is used only to normalize whitespace, condensing "blocks" down to a
* single space, thus matching the same would likely cause a great
* many noop replacements.
*/
private static final Pattern WHITESPACE_PATTERN = Pattern.compile("(?: \\s|[\\s&&[^ ]])\\s*");