// 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) 
import java.util.regex.*;

public class Regex {
    private static Pattern p = Pattern.compile("[^d]*[d][^d]*");
    private static boolean dCheck(String s) {
        return p.matcher(s).matches();
    }
    private static void test(String s) {
        System.out.println("#" + s + "# " + dCheck(s));
        return;
    }
    public static void main(String[] args) {
        test("abc");
        test("d");
        test("dd");
        test("ddd");
        test("cde");
        test("xddx");
    }
}
