Bash script check string for uppercase letter
问题 I am trying to check a string for any Uppercase letter. my code shows NO UPPER for any input, may it be "sss", "Sss", "SSS" if [[ "$pass" =~ [^a-zA-Z0-9] ]] then echo "Upper found" else echo "no upper" fi 回答1: [^a-zA-Z0-9] means anything except for a-z , i.e. lowercase letters, A-Z , i.e. uppercase letters, and 0-9 , i.e. digits. sss , Sss , SSS all contain just letters, so they can't match. [[ $password =~ [A-Z] ]] is true if the password contains any uppercase letter. You should set LC_ALL