title: Equivalent Javascript substr_count?
body: <p>I am trying to find an equivalent function for Javascript.  What I am trying to do is look for the current URL and if it has the following first part of the URL then do something.</p>
  
  <p>In PHP I have this</p>
  
  <pre><code>if (substr_count($current_url, $root . $_SERVER['SERVER_NAME'] . '/shop/shop-gallery') {
   doSomething();
  }
  </code></pre>
  
  <p>So as long as it matches that URL and all sub URLs like /shop/shop-gallery/product1..etc, the statement will be true.</p>
  
  <p>Now how can I execute the same exact statement in javascript?</p>
  
  <p>Thanks guys!</p>