Changed the if clauses to use zsh regex style