title: Redshift Extract String Between Two Patterns (regexp_substr)
body: <p>I'm trying to extract the text following <code>deviceSerialNumber=</code> that occurs until either a <code>&amp;</code> or the end of the string. Data looks like</p>
  
  <blockquote>
    <p>someddata&amp;=somedataagain&amp;deviceSerialNumber=device12345&amp;anotherField=moreData
    someddata&amp;=somedataagain&amp;deviceSerialNumber=deviceabcd</p>
  </blockquote>
  
  <p>I've tried this</p>
  
  <pre><code>REGEXP_SUBSTR(session_tags || '&amp;', 'deviceSerialNumber(.*)&amp;') from table
  </code></pre>
  
  <p>but, this returns all of the text until the final <code>&amp;</code> (which is the end of the string, since I'm appending a <code>&amp;</code> for pattern matching purposes). How do I have to modify this regular expression to extract only the text until the first <code>&amp;</code>?</p>