title: Match Url path without query string
body: <p>I would like to match a path in a Url, but ignoring the querystring.
  The regex should include an optional trailing slash before the querystring.</p>
  
  <p>Example urls that should give a valid match:</p>
  
  <pre><code>/path/?a=123&amp;b=123
  
  /path?a=123&amp;b=123
  </code></pre>
  
  <p>So the string '/path' should match either of the above urls.</p>
  
  <p>I have tried the following regex: <code>(/path[^?]+).*</code></p>
  
  <p>But this will only match urls like the first example above: <code>/path/?a=123&amp;b=123</code></p>
  
  <p>Any idea how i would go about getting it to match the second example without the trailing slash as well?</p>
  
  <p>Regex is a requirement.</p>