Simplify this document.referrer check Can this be simplified in any way?

if ($('.content').length &amp;&amp; (document.referrer.search('page1.html') &gt; 0) ||
    $('.content').length &amp;&amp; (document.referrer.search('page2.html') &gt; 0) ||
    $('.content').length &amp;&amp; (document.referrer.search('page3.html') &gt; 0) ||
    $('.content').length &amp;&amp; (document.referrer.search('page4.html') &gt; 0) ||
    $('.content').length &amp;&amp; (document.referrer.search('page5.html') &gt; 0) ||
    $('.content').length &amp;&amp; (document.referrer.search('page6.html') &gt; 0) ||
    $('.content').length &amp;&amp; (document.referrer.search('page7.html') &gt; 0) ||
    $('.content').length &amp;&amp; (document.referrer.search('search/?') &gt; 0)) {
        window.location.href = document.referrer;
};
Easily! You can use a regular expression to match page[1-7].html and also search/?:

if ($('.content').length &amp;&amp; document.referrer.match(/page[1-7]\.html|search\/\?/)) {
        window.location.href = document.referrer;
};


And never write conditions in such wasteful way:


if (A &amp;&amp; B || A &amp;&amp; C || A &amp;&amp; D) {



when it can be easily simplified to:

if (A &amp;&amp; (B || C || D)) {