public static String normalize( String text ) {
        CheckArg.isNotNull(text, "text");
        // This could be much more efficient.
        return NORMALIZE_PATTERN.matcher(text).replaceAll(" ").trim();
    }
public static String normalize ( String text ) { CheckArg . isNotNull ( text , "text" ) ; return NORMALIZE_PATTERN . matcher ( text ) . replaceAll ( " " ) . trim ( ) ; }
Removes leading and trailing whitespace from the supplied text, and reduces other consecutive whitespace characters to a
single space. Whitespace includes line-feeds.

@param text the text to be normalized
@return the normalized text