title: REGEXP_SUBSTR function in Redshift does not return expected value
body: <p>I have a table with column called URL. I am trying to extract different parts of URL using <code>REGEX_SUBSTR</code> function in Redshift.</p>
  
  <pre><code>URL                                             Expected_output
  ------------                                 
  www.abcd.com/first-name                      |   first-name
  www.abcd.com/another-name/some-details/other |   another-name
  www3.abcd.com/some-name/                     |   some-name
  form.abcd.com/another-first-name             |   another-first-name
  </code></pre>
  
  <p>So the intention is to extract the first slug after the domain name</p>
  
  <p>I tried<br>
  <code>SELECT REGEXP_SUBSTR('www.abcd.com/slug-name', '(www|www3|form)[.]abcd[.][^/]+/([^/#?]+)',1,2)</code></p>
  
  <p>Output<br>
  <code>www.abcd.com/slug-name</code></p>