我正在使用Bash Shell脚本中的正则表达式。我使用以下正则表达式代码来检查密码标准:密码长度至少为6个字符,其中至少有一个数字和至少一个大写字母。我在正则表达式验证工具中进行了验证,我形成的正则表达式可以正常工作。但是,在Bash Shell脚本中它失败了。请提供您的想法。
echo "Please enter password for User to be created in OIM: "
echo "******Please Note: Password should be at least 6 characters long with one digit and one Upper case Alphabet******"
read user_passwd
regex="^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)\S{6,}$"
echo $user_passwd
echo $regex
if [[ $user_passwd =~ $regex ]]; then
echolog "Password Matches the criteria"
else
echo "Password criteria: Password should be at least 6 characters long with one digit and one Upper case Alphabet"
echo "Password does not Match the criteria, exiting..."
exit
fi