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