I was trying to use a bash script to validate some strings. No matter what I've tried, the script ends up matching every string provided as input and it's printing yes in the terminal. For example, ABCDCD should print itself and "yes", whereas SSSS should just print itself. However, both seem to be printing themselves and "yes".
#! /bin/bash
read str
echo $str
reg1="AB[CD]*"
if [ $str=~$reg1 ];then
echo "yes"
fi