Replace comparison with str.is{upper,digit}