title: Get URL parameter function that gets value of url part or returns true if it's there but with no value?
body: <p>I'm using the following function to get a URL parameter.</p>
  
  <pre><code>function gup(name, url) {
    name = name.replace(/[\[]/, '\\\[').replace(/[\]]/, '\\\]');
    var results = new RegExp('[\\?&amp;]'+name+'=?([^&amp;#]*)').exec(url || window.location.href);
    return results == null ? null : results[1];
  }
  </code></pre>
  
  <p>It works only if the parameter has a value, for example.</p>
  
  <pre><code>gup('a', 'http://example.com/page.php?a=1&amp;b=2');
  </code></pre>
  
  <p>will return 1. But if I try</p>
  
  <pre><code>gup('a', 'http://example.com/page.php?a&amp;b=2');
  </code></pre>
  
  <p>It returns null. I want it to return true because parameter "a" exists in that url, even though it has no value it's still there and gup() should return true. Could I get a bit of help rewriting this? I'm not that good with regex.</p>