@Test public void testremoveWhiteSpace() { ConvertString convertString = new ConvertString(); String input = "a b\t\t\tc\n\n\nd\r\re\f\ff"; String cleanStr = convertString.removeRepeatedWhitespaces(input); Assert.assertEquals("a b\tc\nd\re\ff", cleanStr); input = "aaab\r\n\r\n\r\nx"; cleanStr = convertString.removeRepeatedWhitespaces(input); Assert.assertEquals("aaab\r\n\r\n\r\nx", cleanStr); input = "a\u0085\u0085\u0085b\u00A0\u00A0c\u1680\u1680d\u180E\u180Ee\u2000\u2000f\u2001\u2001g" + "\u2002\u2002h\u2003\u2003i\u2004\u2004"; cleanStr = convertString.removeRepeatedWhitespaces(input); Assert.assertEquals("a\u0085b\u00A0c\u1680d\u180Ee\u2000f\u2001g\u2002h\u2003i\u2004", cleanStr); input = "a\u2005\u2005\u2005b\u2006\u2006c\u2007\u2007d\u2008\u2008e\u2009\u2009f\u200A\u200Ag" + "\u2028\u2028h\u2029\u2029i\u202F\u202Fj\u205F\u205Fk\u3000\u3000l"; cleanStr = convertString.removeRepeatedWhitespaces(input); Assert.assertEquals("a\u2005b\u2006c\u2007d\u2008e\u2009f\u200Ag\u2028h\u2029i\u202Fj\u205Fk\u3000l", cleanStr); }
public String removeRepeatedWhitespaces(String input) { if (StringUtils.isEmpty(input) || removeWhiteSpacesPattern == null) { return input; } Matcher matcher = removeWhiteSpacesPattern.matcher(input); return matcher.replaceAll("$1"); }
ConvertString { public String removeRepeatedWhitespaces(String input) { if (StringUtils.isEmpty(input) || removeWhiteSpacesPattern == null) { return input; } Matcher matcher = removeWhiteSpacesPattern.matcher(input); return matcher.replaceAll("$1"); } }
ConvertString { public String removeRepeatedWhitespaces(String input) { if (StringUtils.isEmpty(input) || removeWhiteSpacesPattern == null) { return input; } Matcher matcher = removeWhiteSpacesPattern.matcher(input); return matcher.replaceAll("$1"); } ConvertString();  ConvertString(String repeatStr); }
ConvertString { public String removeRepeatedWhitespaces(String input) { if (StringUtils.isEmpty(input) || removeWhiteSpacesPattern == null) { return input; } Matcher matcher = removeWhiteSpacesPattern.matcher(input); return matcher.replaceAll("$1"); } ConvertString();  ConvertString(String repeatStr); String removeTrailingAndLeadingWhitespaces(String input); String removeTrailingAndLeading(String input); String removeTrailingAndLeading(String input, String character); String removeRepeatedChar(String input); String removeRepeatedWhitespaces(String input); }
ConvertString { public String removeRepeatedWhitespaces(String input) { if (StringUtils.isEmpty(input) || removeWhiteSpacesPattern == null) { return input; } Matcher matcher = removeWhiteSpacesPattern.matcher(input); return matcher.replaceAll("$1"); } ConvertString();  ConvertString(String repeatStr); String removeTrailingAndLeadingWhitespaces(String input); String removeTrailingAndLeading(String input); String removeTrailingAndLeading(String input, String character); String removeRepeatedChar(String input); String removeRepeatedWhitespaces(String input); static final String[] WHITESPACE_CHARS; }