Here you can find the source of replaceWhiteSpaces(final String value, final String replaceBy)
Parameter | Description |
---|---|
value | input value |
replaceBy | replacement string |
public static String replaceWhiteSpaces(final String value, final String replaceBy)
//package com.java2s; import java.util.regex.Pattern; public class Main { /** RegExp expression to match white spaces (1..n) */ private final static Pattern PATTERN_WHITE_SPACE_MULTIPLE = Pattern.compile("\\s+"); /**/* w ww . ja v a 2 s .c o m*/ * Replace white space characters (1..n) by the given replacement string * @param value input value * @param replaceBy replacement string * @return string value */ public static String replaceWhiteSpaces(final String value, final String replaceBy) { return PATTERN_WHITE_SPACE_MULTIPLE.matcher(value).replaceAll(replaceBy); } }