title: Regular expression to get base url
body: <p>I got a very long string that cointains querystrings and and some regular site urls in it. it looks something like</p>
  
  <pre><code>http://www.mysite.com/site/site?pageId=1234&amp;otherId=4321
  </code></pre>
  
  <p>I would like to get just the <code>http://www.mysite.com</code> from this string. Im thinking maybe a regular expression could do the trick, but Im def not quilfied to write any of that :) so could i get some help? </p>
  
  <p><strong>EDIT</strong><br />
  i need a solution so i can pass url string and get the base url from that. Not my current Url</p>
  
  <p>thanks guys, appreciate it as always. </p>