Java String Clean cleanText(final String input)

Here you can find the source of cleanText(final String input)

Description

Cleans a string for of insignificant whitespace

License

GNU General Public License

Declaration

private static String cleanText(final String input) 

Method Source Code

//package com.java2s;

public class Main {
    /** Cleans a string for of insignificant whitespace */
    private static String cleanText(final String input) {
        if (input == null)
            return "";
        /* get rid of line breaks */
        String retValue = input.replaceAll("\\r\\n|\\r|\\n|\\t", " ");
        /* get rid of double spaces */
        while (retValue.indexOf("  ") != -1)
            retValue = retValue.replaceAll("  ", " ");

        return retValue;
    }/*from   w  w w  .j  a v  a 2s  .c  o m*/
}

Related

  1. cleanStringCamelCase(String in)
  2. cleanStringForFilename(String originalString)
  3. cleanStringForFilePath(final String dirty)
  4. cleanStringForJavaName(String original)
  5. cleanStringFromWhitespaces(String text)
  6. cleanText(String s)
  7. cleanText(String s)
  8. cleanText(String t)
  9. cleanText(String text)