I try to use REGEX in bash in order to check if the parameter seems to be a valid path following this format : /first/second
In java I use with success the following REGEX :
((\/)[a-zA-Z0-9\s_@\-!#$%&+=]+)+
But in bash I have somme issue that I can't explain. In order to simplify my comprehension I try to use a simpler REGEX like that :
CHECKPATH="!/first/second"
REGEX_PATH="((\/)[a-zA-Z0-9]+)+"
if [[ ! ${CHECKPATH} =~ $REGEX_PATH ]]; then
echo "error"
else
echo "OK"
fi
I insert an "!" in the path just to check. So I should have "error" but not. With or without the "!" it changes nothing, what's the problem ?
Aucun commentaire:
Enregistrer un commentaire