RegExp method "test" return wrong result <p>Acoording to <a href="https://regex101.com/" rel="nofollow">https://regex101.com/</a> regexp <code>'^[-+]?[0-9]*\.?[0-9]$'</code> for strings like "g2", "a8" etc. (one digit preceded by one letter) should return "false" (no match), but if I use it in JavaScript using <code>RegExp</code> <code>test</code> method "true" is returned. What is the reason of that behaviour?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;body&gt; &lt;button onclick="myFunction()"&gt;Try it&lt;/button&gt; &lt;p id="demo"&gt;&lt;/p&gt; &lt;script&gt; function myFunction() { var str = "g2"; var patt = new RegExp('^[-+]?[0-9]*\.?[0-9]$'); var res = patt.test(str); document.getElementById("demo").innerHTML = res; } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>