title: Remove querystring parameters from url with regex
body: <p>I'm pretty new to regex and need to remove some content from our url</p>
  
  <pre><code> http://mysite.blah/problem/smtp/smtp-open-relay?page=prob_detail&amp;showlogin=1&amp;action=smtp:134.184.90.18
  </code></pre>
  
  <p>I need to remove everything from the "?" and on, leaving me just: </p>
  
  <pre><code>http://mysite.blah/problem/smtp/smtp-open-relay
  </code></pre>
  
  <p>Here is our current regex expression we are using to grab the route data. For example I can grab "smtp" and "smtp-open-relay" (which we need). However sometimes our url changes depending on where the user is coming from thereby appending the querystring parameters which is causing our current regex expression to blow up.</p>
  
  <pre><code>// Retrieve the route data from the route
  var routeData = /([0-9a-zA-Z_.-]+)\/([0-9a-zA-Z_.-]+)$/g.exec(route);
  </code></pre>
  
  <p>I need it to ignore stuff from the "?" on.</p>