Getting part of string using jQuery .search results in null
<p>I need to extract the page number from URL string similar to:</p>

<pre><code>http://www.example.com/index.php?paged=2
</code></pre>

<p>I am able to retrieve the same using:</p>

<pre><code>page_number = this.search.match(/paged=(\d+)/)[1];
</code></pre>

<p>This gives me "2" as result. However, at times the URL does not contain any page number, like:</p>

<pre><code>http://www.example.com/index.php
</code></pre>

<p>This is where the problem crops up. jQuery throws the error <code>this.search.match(/paged=(\d+)/) is null</code>. How do I overcome the null error? I do not find a method to check for null. Also I have tried <code>if((this.search.match(/paged=(\d+)/)[1]).length &gt; 0 )</code>. But this also results in the same error.</p>

<p>Regards,
John</p>
