Java Regex include all letters of the alphabet except certain letters
'&&' didn't work for me,
used: (?:(?![IVX])[A-Z])
You can use the &&
operator to create a compound character class using subtraction:
String regex = "[A-Z&&[^IVX]]+";
Just use a negative lookahead in your pattern.
Pattern pattern = Pattern.compile("^(?:(?![IVX])[A-Z])+$");
DEMO
You could simply specify character ranges inside your character class:
[A-HJ-UWYZ]+