Here you can find the source of replaceWhiteSpacesByMinusSign(final String value)
Parameter | Description |
---|---|
value | input value |
public static String replaceWhiteSpacesByMinusSign(final String value)
//package com.java2s; import java.util.regex.Pattern; public class Main { /** String constant containing 1 minus sign character '-' */ public final static String STRING_MINUS_SIGN = "-"; /** RegExp expression to match white spaces (1..n) */ private final static Pattern PATTERN_WHITE_SPACE_MULTIPLE = Pattern.compile("\\s+"); /**//from www .ja va2 s .com * Replace white space characters (1..n) by the minus sign character * @param value input value * @return string value */ public static String replaceWhiteSpacesByMinusSign(final String value) { return replaceWhiteSpaces(value, STRING_MINUS_SIGN); } /** * 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); } }