From 8a946932c8306816fd23196ec14dee3e3ac8e9f1 Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Fri, 9 Nov 2012 16:50:39 +0000 Subject: [PATCH] explain whitespace pattern git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1407537 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/java/org/apache/commons/lang3/StringUtils.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index 81584067b..548af53b5 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -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*");