JavaScript - I get an error in Firebug
<p>I am searching through a string trying to count the number of occurrences of @@ (two @ signs in a row).  My code works well when the count is greater than 0, but I get an error in Firebug when the occurrence is zero.</p>

<p>This throws an error:</p>

<pre><code>var str = "This string has no at signs!";
var pcount = str.match(/@@/g).length;
alert(pcount);

var str = "This string has @@ one pair of signs!";
var pcount = str.match(/@@/g).length;
alert(pcount);

var str = "This @@ string has @@ two pairs of signs!";
var pcount = str.match(/@@/g).length;
alert(pcount);
</code></pre>

<p>The error I get in Firebug is:</p>

<pre><code>str.match(/@@/g) is null
[Break On This Error] var pcount = str.match(/@@/g).length;
</code></pre>

<p>What I want is for pcount to be zero if no @@ is found.</p>

<p>Can you help? </p>

<p>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ANSWER</p>

<p>I ended up using a combination of your answers.  Thanks so much for your help!!!</p>

<pre><code>var NewRows = getRowCount(ThisTextLen);
var Match = ThisText.match(/@@/g);
var ParagraphCount = 0;
if (Match != null) {
    ParagraphCount = ThisText.match(/@@/g).length;
    NewRows = NewRows + ParagraphCount;
}
</code></pre>
