Java Number Min Value minimiseSpaces(String input)

Here you can find the source of minimiseSpaces(String input)

Description

minimise Spaces

License

Open Source License

Declaration

public static String minimiseSpaces(String input) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String minimiseSpaces(String input) {

        return repeatedlyReplace(input, "  ", " ");
    }/*  w w w .j  a  v  a 2 s  .co  m*/

    /**
     * Keep replacing the given string until they are all gone - a multi-pass rather than 
     * the normal single pass of replaceAll
     * 
     * @param string
     * @param doomed
     * @param newbie
     * @return The string with all the doomed strings replaced with the newbie strings
     */
    public static String repeatedlyReplace(String string, String doomed, String newbie) {

        String cleaned = string.replaceAll(doomed, newbie);
        while (cleaned.length() != string.length()) {
            string = cleaned;
            cleaned = string.replaceAll(doomed, newbie);
        }
        return cleaned;
    }
}

Related

  1. minFileBuf(long fileSize, int bufSize)
  2. minifiedJS(String url)
  3. minifyPubkey(String pubkey)
  4. minIgnoreNull(Integer a, Integer b)
  5. minimalIndexOf(String str, String separators, int startIndex)
  6. minimize(final StringBuilder src)
  7. minimizeWhitespace(String str)
  8. minimum(float first, float second)
  9. Minimum(float x, float y)