 <p>Problem is presence of <code>!</code> in your character class that is doing history expansion.</p> <p>I suggest declaring your regex beforehand like this:</p> <pre><code>re="^[0-9][0-9a-zA-Z\!#$%^&amp;/*'+-]+$" </code></pre> <p>Then use it as:</p> <pre><code>s='1/' [[ $s =~ $re ]] &amp;&amp; echo "good" || echo "bad" good </code></pre>