Advertisement
Guest User

Untitled

a guest
Nov 21st, 2013
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. String[] strings = {
  2.  
  3. //False
  4. "test-metareg-rw40lntknahvpseba32cßáàâåäæç",
  5. "test-metareg--rw40lntknahvpseba32cßáàâåäæç",
  6. "test-metareg-rw40lntknahvpseba32c-",
  7. "12345678901234567890123456789012345678901234567890123456789012-",
  8. "123456789012345678901234567890123456789012345678901234567890124-",
  9.  
  10.  
  11. //True
  12. "test-metareg-rw40lntknahvpseba32c",
  13. "testmetareg",
  14. "123456789012345678901234567890123456789012345678901234567890123",
  15.  
  16.  
  17. };
  18.  
  19.  
  20.  
  21.  
  22. for (String string : strings) {
  23. Pattern compile = Pattern.compile("(?=[a-z0-9-]{1,63}$)([a-z0-9]++-){0,63}[a-z0-9]+");
  24. Matcher matcher = compile.matcher(string);
  25. boolean matches = matcher.matches(); //Takes 30+ seconds
  26. System.out.println(matches);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement