View difference between Paste ID: y1fkaZ47 and Kuis6wYx
SHOW: | | - or go back to the newest paste.
1
String[] strings = {
2
3
                //False
4
                "test-metareg-rw40lntknahvpseba32cßáàâåäæç",
5
                "test-metareg--rw40lntknahvpseba32cßáàâåäæç",
6
                "test-metareg-rw40lntknahvpseba32c-",
7-
                "123456789012345678901234567890123456789012345678901234567890123-",
7+
                "12345678901234567890123456789012345678901234567890123456789012-",
8-
                "1234567890123456789012345678901234567890123456789012345678901234-",
8+
                "123456789012345678901234567890123456789012345678901234567890124-",
9
10
11
                //True
12
                "test-metareg-rw40lntknahvpseba32c",
13
                "testmetareg",
14-
                "1234567890123456789012345678901234567890123456789012345678901234",
14+
                "123456789012345678901234567890123456789012345678901234567890123",
15
16
17
        };
18
19
20
21
22
        for (String string : strings) {
23-
            Pattern compile = Pattern.compile("(?=[a-z0-9-]{1,64}$)([a-z0-9]++-){0,63}[a-z0-9]+");
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
        }