title: Extract Specific Parameter value using Regex Postgresql
body: <p>Given input string as</p>
  <pre><code>'PARAM_1=TRUE,THRESHOLDLIST=kWh,2000,Gallons,1000,litre,3000,PARAM_2=TRUE,PARAM_3=abc,123,kWh,800,Gallons,500'
  </code></pre>
  <p>and unit_param = 'Gallons'
  I need to extract value of unit_param (Gallons) which is 1000 using postgresql regex functions.</p>
  <p>As of now, I have a function that first extracts value for THRESHOLDLIST which is &quot;kWh,2000,Gallons,1000,litre,3000&quot;, then splits and loops over the array to get the value.</p>
  <p>Can I get this efficiently using regex.</p>
  <pre><code>SELECT substring('PARAM_1=TRUE,THRESHOLDLIST=kWh,2000,Gallons,1000,litre,3000,PARAM_2=TRUE,PARAM_3=abc,123,xyz' FROM '%THRESHOLDLIST=#&quot;.........#&quot;,%' FOR '#')
  </code></pre>