fork download
  1. /* Name of the class has to be "Main" only if the class is public. */
  2. class Ideone
  3. {
  4. private static String pattern = ".*[04-9].*";
  5.  
  6. public static void main (String[] args) throws java.lang.Exception {
  7. test("ABC0123", false);
  8. test("XYZ002456789", false);
  9. test("ABC123", true);
  10. test("ABC1", true);
  11. }
  12.  
  13. private static void test(String str, boolean expect) {
  14. boolean result = !str.matches(pattern); // ! because that's your *dis*allow
  15. System.out.println(str + " => " + result + (result == expect ? " OK" : " *ERROR*"));
  16. }
  17. }
  18.  
Success #stdin #stdout 0.09s 2184192KB
stdin
Standard input is empty
stdout
ABC0123 => false OK
XYZ002456789 => false OK
ABC123 => true OK
ABC1 => true OK