Replace usage of regex ("=~")

It's not really necessary and may cause problems on Zsh, when the regex
module cannot be loaded. This might happen on a minimal system.