import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Pattern;
import java.util.stream.IntStream;

import static java.lang.System.out;
import static java.util.stream.Collectors.toCollection;

public class JDK_PatternExperiments
{
    public static void main( String... args )
    {
        var p = Pattern.compile("[a-z&&[^a]a&&x]");

        var matches = IntStream.rangeClosed('a', 'z').mapToObj(Character::toString).filter(p.asMatchPredicate()).collect( toCollection(TreeSet::new) );

        out.printf("matches: %s\n", matches);
        if( ! Set.of("x").equals(matches) )
            throw new AssertionError();
    }
} 