String patt = "^Q[^u]\\d+\\."; RE r = new RE(patt); for (int i=0; i<argv.length; i++) { boolean found = r.match(argv[i]); System.out.println(patt + (found ? " matches " : " doesn't match ") + argv[i]); }