mardi 27 juin 2017

Bash to test regex-match, seems to always return OK even not match

I'm under bash and tried to match a short string with a pattern:

$[[ "ab" =~ "^a*" ]]
$echo $?
0

OK, as I expected, but then I changed into "^b*", I expect this time, it doesn't match:

$[[ "ab" =~ "^b*" ]]
$echo $?
0

Strangely the return value is still "OK". Why is that, where did I get wrong? Thanks.

Aucun commentaire:

Enregistrer un commentaire