title: Getting URL parameters and filter out a specific parameter
body: <p>I want to filter out a specific parameter out of the URL. I have the following situation:</p>
  
  <ol>
  <li>The page got loaded (for example: <a href="http://test.com/default.aspx?folder=app&amp;test=true" rel="nofollow noreferrer">http://test.com/default.aspx?folder=app&amp;test=true</a>)</li>
  <li>When the page is loaded a function is called to push a entry to the history (pushState): ( for example: <a href="http://test.com/default.aspx?folder=app&amp;test=true&amp;state=1" rel="nofollow noreferrer">http://test.com/default.aspx?folder=app&amp;test=true&amp;state=1</a>)</li>
  <li>Now I want to call a function that reads all the parameters and output all these parameters expect for the <strong>state</strong>. So that I end up with: "?folder=app&amp;test=true" (just a string value, no array or object). Please keep in mind that I do not know what all the names of the parameters are execpt for the <code>state</code> parameter</li>
  </ol>
  
  <p><strong>What I have tried</strong></p>
  
  <p>I know I can get all the parameters by using the following code:</p>
  
  <pre><code>window.location.search
  </code></pre>
  
  <p>But it will result in:</p>
  
  <p><code>?folder=app&amp;test=true&amp;state=1</code></p>
  
  <p>I try to split the url, for example:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var url = '?folder=app&amp;test=true&amp;state=1';
  url = url.split('&amp;state=');
  console.log(url);</code></pre>
  </div>
  </div>
  </p>
  
  <p>But that does not work. Also because the <code>state</code> number is <strong>dynamic</strong> in each request. A solution might be remove the last parameter out of the url but I also do not know if that ever will be the case therefore I need some filtering mechanisme that will only filter out the </p>
  
  <pre><code>state=/*regex for a number*/
  </code></pre>