The best way to do this is to simply update the range to exclude letters that you do not want. That would leave you with this:
/^[a-pr-uwyzA-PR-UWYZęóąśłżźćńĘÓĄŚŁŻŹĆŃ]+$/
You can cross out the character class subtraction form with a negative view. However, it will be less efficient since you are repeating a negative result for each row. In any case, here's what it would look like:
/^(?:(?![qvxQVX])[a-zA-ZęóąśłżźćńĘÓĄŚŁŻŹĆŃ])+$/
This works best if you don't repeat the character class an unlimited number of times.
Several varieties of regular expressions, including Java and .NET, efficiently support character class subtraction using special syntax.
In Java, intersect with a negative group:
/^[a-zA-ZęóąśłżźćńĘÓĄŚŁŻŹĆŃ&&[^qvxQVX]]+$/
A little-known fact is that the Opera web browser actually supports the above Java syntax in its own JavaScript regular expressions. Opera may remove this feature in the future because it is non-standard (it is based on abandoned ES4 offers), but it works in the current version (v11.64), at least.
.NET, XPath, and XML Schema support the following, simpler syntax for subtracting a character class:
/^[a-zA-ZęóąśłżźćńĘÓĄŚŁŻŹĆŃ-[qvxQVX]]+$/
source share