title: Return which element matched each row in SQL result
body: <p>I am programmatically writing SQL queries from user input. I want to show the user for each row returned, which part of their supplied query information matched against that row.</p>
  <p>For instance user supplied information looks like:</p>
  <pre><code>red:[11,202]
  blue:[36]
  green:[202]
  yellow:[11,36]
  </code></pre>
  <p>This information would build the following query:</p>
  <pre class="lang-sql prettyprint-override"><code>SELECT name, list FROM test WHERE list SIMILAR TO '%(11|202|36)%'
  </code></pre>
  <p>But I would like to add a result field similar to the &quot;Matched Element shown below:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>name</th>
  <th>list</th>
  <th>Matched Element</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>foobar</td>
  <td>15,11,19,20</td>
  <td>red, yellow</td>
  </tr>
  <tr>
  <td>hello</td>
  <td>17,30,36,20</td>
  <td>blue, yellow</td>
  </tr>
  <tr>
  <td>bar</td>
  <td>101,202,330,460</td>
  <td>red, green</td>
  </tr>
  <tr>
  <td>test</td>
  <td>15,36,23</td>
  <td>blue</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I cannot add attempted examples as I do not know the proper language by which to seach for information. My current solution so far is to process the data row by row after the query has returned the result to my script to add the new column, but I would like to know if its possible to achieve this using postgres.</p>
  <p>Here is a db-fiddle: <a href="https://www.db-fiddle.com/f/nMMB3wVFRTGeZgobmA4F6k/2" rel="nofollow noreferrer">https://www.db-fiddle.com/f/nMMB3wVFRTGeZgobmA4F6k/1</a></p>
  <p>I am running postgresql 12.3 however I am able to change version if needed.</p>