title: RegEx for extracting url parameters
body: <p>I need to extract url parameters from the following string</p>
  
  <pre><code>?theAccount=someData&amp;theToken=sometoken&amp;mediaId=someid
  </code></pre>
  
  <p>so I want <code>someData sometoken someid</code></p>
  
  <p>here is the function I am using </p>
  
  <pre><code>function getParams( name ) {
              var str = window.location.search;
              var r = new RegExp("/(^\?|&amp;+)"+name+"(\=)/");
              var result =  r.exec(str);
              if (r) { return result; }
              return "";
  
          }
  </code></pre>
  
  <p>called like so <code>getParams(theAccount);</code></p>
  
  <p>But it's not working and keeps "invalid regular expression". Any help is much appreciated.</p>