import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TestRegex {

    public static void main(String[] args) {
        System.out.println(System.getProperty("java.vm.name"));
        System.out.println(System.getProperty("java.vm.vendor"));
        System.out.println(System.getProperty("java.vm.version"));

        System.out.println("Running Test");
        String[] testRegex = new String[] { "([^0-9a-z&&[^\\s]])(?!\\1)", "([^0-9a-z&&[\\s]])(?!\\1)", "([\\S&&[\\w]])(?!\\1)", "([\\S&&[\\W]])(?!\\1)" };
        String text = "aabcc \n\n\t\t\n \n\n..,;;";
        System.out.println("Text: " + printable(text));
        System.out.println();
        for (String regex : testRegex) {
            Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
            System.out.println("Pattern: " + pattern.pattern());
            Matcher m = pattern.matcher(text);
            while (m.find()) {
                System.out
                        .println("\tIndex: " + m.start() + ", " + m.end() + " Group: " + printable(m.group()) + " Next Char: " + printable((m.end() < text.length() ? "" + text.charAt(m.end()) : "")));
            }
        }

    }

    public static String printable(String text) {
        text = text.replaceAll("\t", "<tab>");
        text = text.replaceAll("\n", "<newline>");
        text = text.replaceAll(" ", "<space>");
        return text;
    }

} 