Package org.apache.regexp

Examples of org.apache.regexp.RE.match()


        String alphabet = "abcdefghijklmnopqrstuvwxyz";
        String numbers = "0123456789";

        assertTrue(re.match(alphabet));
        assertTrue(re.match(alphabet.toUpperCase()));
        assertTrue(re.match(numbers));

        assertTrue(re.match("a_sentence.that-has@separators"));

        // Should match first part of string (up to '*' which is an illegal char)
        assertTrue(re.match("a_sentence.th*at-has@separators"));
 
View Full Code Here


        assertTrue(re.match(alphabet));
        assertTrue(re.match(alphabet.toUpperCase()));
        assertTrue(re.match(numbers));

        assertTrue(re.match("a_sentence.that-has@separators"));

        // Should match first part of string (up to '*' which is an illegal char)
        assertTrue(re.match("a_sentence.th*at-has@separators"));

        char validOtherChars[] = {
View Full Code Here

        assertTrue(re.match(numbers));

        assertTrue(re.match("a_sentence.that-has@separators"));

        // Should match first part of string (up to '*' which is an illegal char)
        assertTrue(re.match("a_sentence.th*at-has@separators"));

        char validOtherChars[] = {
            '.', '_', '.', '-', '@'
        };
        // Test that each valid char may be matched individually.
View Full Code Here

            '.', '_', '.', '-', '@'
        };
        // Test that each valid char may be matched individually.
        for (int i = 0; i < validOtherChars.length; i++) {
            String str = String.valueOf(validOtherChars[i]);
            assertTrue("Value should match: '" + str + "'", re.match(str));
        }
        assertTrue(re.match(new String(validOtherChars)));

        String allValidChars = alphabet.toLowerCase() + numbers +
                String.valueOf(validOtherChars) + alphabet.toUpperCase();
View Full Code Here

        // Test that each valid char may be matched individually.
        for (int i = 0; i < validOtherChars.length; i++) {
            String str = String.valueOf(validOtherChars[i]);
            assertTrue("Value should match: '" + str + "'", re.match(str));
        }
        assertTrue(re.match(new String(validOtherChars)));

        String allValidChars = alphabet.toLowerCase() + numbers +
                String.valueOf(validOtherChars) + alphabet.toUpperCase();

        for (int i = 0; i < allValidChars.length(); i++) {
View Full Code Here

                String.valueOf(validOtherChars) + alphabet.toUpperCase();

        for (int i = 0; i < allValidChars.length(); i++) {
            String str = String.valueOf(allValidChars.charAt(i));
            assertTrue("Value should match: '" + str + "' in " + allValidChars +
                    " at position " + i, re.match(str));
        }

        char someInvalidChars[] = {
            '`', '~', '*', '!', '<', '>', '(', ')', '[', ']', '^', '$', '|',
            '?', ',', '\'', ':', '"', ';', '{', '}', '=', '+', '&', '%', '/'
View Full Code Here

            '?', ',', '\'', ':', '"', ';', '{', '}', '=', '+', '&', '%', '/'
        };

        for (int i = 0; i < someInvalidChars.length; i++) {
            String str = String.valueOf(someInvalidChars[i]);
            assertFalse("Value should NOT match: '" + str + "'", re.match(str));
        }

        // This will not match only if all the characters are invalid. If we
        // insert even just one valid character, the RE will match that char
        // and return true.
View Full Code Here

        }

        // This will not match only if all the characters are invalid. If we
        // insert even just one valid character, the RE will match that char
        // and return true.
        assertFalse(re.match(String.valueOf(someInvalidChars)));
    }
}

/*
===========================================================================
View Full Code Here

     *
     * @return Scheme of the URI.
     */
    public static String getScheme(String uri) {
        RE re = new RE(uripattern);
        if (re.match(uri)) {
            return re.getParen(2);
        } else {
            throw new IllegalArgumentException("'" + uri +
                                               "' is not a correct URI");
        }
View Full Code Here

     *
     * @return Scheme of the URI.
     */
    public static String getAuthority(String uri) {
        RE re = new RE(uripattern);
        if (re.match(uri)) {
            return re.getParen(4);
        } else {
            throw new IllegalArgumentException("'" + uri +
                                               "' is not a correct URI");
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.