title: SQL SERVER get hostname and path but not parameters
body: <p>I have to get the hostname &amp; pathname from an URL using regular expression.</p>
  
  <p>URL can be in the form of </p>
  
  <p>a) <code>http://test.com/mary/archive/project.aspx</code> --> I want <code>http::/test.com/mary</code><br>
  b) <code>http://www.testmary.com/company</code> --> I want <code>http://www.testmary.com/</code><br>
  c) <code>http://marytest.com/b/about/</code>--> I want <code>http://marytest.com/</code><br>
  d) <code>http://mary.test.com/b/mary/project.aspx</code> --> I want <code>http://mary.test.com/b/mary/</code>  </p>
  
  <p>Basically I am looking get records that have url "mary" and get only hostname or pathname depending on where "mary" is.</p>
  
  <p>Any help is appreciated.</p>
  
  <p>Thanks
  R </p>