I need to check a string and make sure that it does not contain any character outside list of given characters.
I wrote one script to test this:
str="$1"
regex="^[0-9a-zA-Z\,\!\-\^\`@\{\}\[\],=\(\).;\/~_|]*$"
if [[ "$str" =~ $regex ]]
then
echo "f yeah"
else
echo "f you"
fi
But it does not seem to work. And it seems to me that I am not even close.
List of allowed characters is :
a-z A-Z 0-9 ` @ { } [ ] ^ , = ! ( ) . ; / ~ _ |
Not sure what I am missing here.