title: substring regex for first part of url
body: <p>I've got a large database of projects and issue trackers, some of which have urls.</p>
  
  <p>I'd like to query it to figure out a list of urls for each project, but many have extra data I'd like to avoid.</p>
  
  <p>I'd like to do something like this:</p>
  
  <pre><code>substring(tracker_extra_field_data.field_data FROM 'http://([^/]*).*')
  </code></pre>
  
  <p>Except some urls are https, and I'd like to capture that as well as the first sub directory.</p>
  
  <p>For example, given the url:</p>
  
  <pre><code>https://dev.foo.com/bar/action/?param=val
  </code></pre>
  
  <p>I'd like the select to return:</p>
  
  <pre><code>https://dev.foo.com/bar/
  </code></pre>
  
  <p>Is there a semi-simple way to do this with substring/regex in pgsql?</p>