public class Main { public static void main(String[] argv) { System.out.println(">" + " asdf ".replaceAll("\\b\\s{2,}\\b", " ") + "<"); } } //> asdf <