// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class Regex2 {
    public static void main(String[] args) {
        String s = "M 0 112 L 20 124 L 40 45 L129 30L 60 -126.32 V -34.342 H -45 Z";
        System.out.println(s);
        System.out.println("M0 112L20 124L40 45L129 30L60-126.32V-34.342H-45Z");
        String s2 = s.replaceAll("([ ]?)([MLVHCSTQAZ]|-)([ ]?)","$2");
        System.out.println(s2);
    }
}
