title: Allow one or zero matches in regex, but prefer one
body: <p>I want to match a query parameter in a url string, for example <code>?foo=bar&amp;para=val</code>.
  I need a regex pattern that looks if there is a <code>foo</code> parameter and returns it's value. If there is no match return an empty string.<br>
  I tried this pattern: <code>/(?:foo=([^&amp;]+))?/</code> but it returns an empty match. It returns the value if I change it to <code>/(foo=([^&amp;]+))+/</code></p>
  
  <p><strong>expected results:</strong></p>
  
  <ul>
  <li><code>?foo=myvalue&amp;bar=bazz</code> should return <code>myvalue</code>  </li>
  <li><code>?bar=bazz</code> should return <code>(empty string)</code></li>
  </ul>
  
  <p>Any ideas?</p>