question: public static String removeExtraSpaces ( String text ) { text = text . replace ( ChineseLanguageConstants . SPACE [ 0 ] , ChineseLanguageConstants . SPACE [ 1 ] ) ; text = text . replaceAll ( "[ \t ]+" , " " ) ; text = text . replaceAll ( "(^ +)|( +$)" , "" ) ; return text ; }
target:  Remove extra spaces, which means more than one continuous spaces will be reduced to one space. Space here is not limited to the %32 white space character, it also includes TAB, space in Chinese full width letter and other special characters which appear as a white space. Spaces in the begin or end of a line are all removed.