Use case-statement instead of [[ =~ ]]

Bash's =~ seems to have variety of version incompatiblities.
Looks to me it's not just Bash's versions, but also
incompatiblity of underlaying regex library.