Regexp.match.length returns NULL if not found
<p>I've a JS regexp. </p>

<pre><code>var t1 = str.match(/\[h1\]/g).length;
</code></pre>

<p>If <code>str</code> contains the word <code>[h1]</code> it works fine else it shows error !<br>
How to solve the problem ?</p>
