I am trying to use the extended regex operators available in bash (?, *, +, @, !). The manual says I just have to enclose with parentheses a list of patterns, then use the operator before the left bracket. So if I want a pattern of zero or more a’s:
if [[ "$1" =~ *(a) ]]
then
echo $1
fi
but this is not working. What am I doing wrong?
Per
man bash:I quoted the whole thing here because I think it’s useful to know. You use standard POSIX extended regular expressions on the right hand side.
In particular, the expression on the right side may match a substring of the left operand. Thus, to match the whole string, use
^and$anchors: