fork download
  1. import java.util.regex.Pattern;
  2.  
  3. class Test {
  4.  
  5. public static void main (String[] args) throws java.lang.Exception {
  6.  
  7. Pattern p = Pattern.compile("(?=^([0-9] *){9,12}[0-9]$)(?=^([0-9]+ ){0,3}[0-9]+$)^.*$");
  8. System.out.println(p.matcher("1234567 90").matches()); // false
  9. System.out.println(p.matcher("123 456 789 0123").matches()); // true
  10. System.out.println(p.matcher("123 456 789 01 23").matches()); // false
  11.  
  12. }
  13.  
  14. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
false
true
false