Replace multiple whitespaces between words with single blank
public class Main { public static void main(String[] argv) { System.out.println(">" + " asdf ".replaceAll("\\b\\s{2,}\\b", " ") + "<"); } } //> asdf <