The is_alpha() and is_alnum() functions fail to recognize strings
containing mixed case and digits (in the case of the latter). This
commit fixes the implementations by making perform the check with a
regular expression instead of delegating the work to is_upper(),
is_lower(), and is_digits().
str="$1"
- if is_upper "$str" || is_lower "$str"; then
+ if [[ "$str" =~ ^[a-zA-Z]+$ ]]; then
return 0
fi
str="$1"
- if is_alpha "$str" || is_digits "$str"; then
+ if [[ "$str" =~ ^[a-zA-Z0-9]+ ]]; then
return 0
fi