This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 21st, 2013  |  syntax: None  |  size: 0.93 KB  |  views: 38  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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.         }
clone this paste RAW Paste Data