fork(1) download
  1. import java.util.*;
  2. import java.util.regex.*;
  3. import java.lang.*;
  4. import java.io.*;
  5.  
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. String lines[] = {"413123123123131", "4131231231231a"};
  11. Pattern p = Pattern.compile("(?=.{9,31}$)\\p{Alnum}*\\p{Alpha}\\p{Alnum}*");
  12. for(String line : lines)
  13. {
  14. Matcher m = p.matcher(line);
  15. if(m.matches()) {
  16. System.out.println(line + ": MATCH");
  17. } else {
  18. System.out.println(line + ": NO MATCH");
  19. }
  20. }
  21. }
  22. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
413123123123131: NO MATCH
4131231231231a: MATCH