title: Parsing URL with regex
body: <p>I'm trying to combine if else inside my regular expression, basically if some patterns exists in the string, capture one pattern, if not, capture another.</p>
  
  <p>The string is:
  '<a href="https://www.searchpage.com/searchcompany.aspx?companyId=41490234&amp;page=0&amp;leftlink=true" rel="nofollow">https://www.searchpage.com/searchcompany.aspx?companyId=41490234&amp;page=0&amp;leftlink=true</a>" and I want to extract staff around the '?"</p>
  
  <p>So if '?' is detected inside the string, the regular expression should capture everything after the '?' mark; if not, then just capture from the beginning.</p>
  
  <p>I used:<code>'(.*\?.*)?(\?.*&amp;.*)|(^&amp;.*)'</code>
  But it didn't work...</p>
  
  <p>Any suggestion?</p>
  
  <p>Thanks!</p>