title: postgres - using SIMILAR TO in a CASE clause
body: <p>I have a column which contains the string of a scanned barcode. I want to find a specific match and return in a new column the string 'match' and 'noMatch'</p>
  
  <p>The regex for the barcode is</p>
  
  <blockquote>
    <p>'[0-9]{5,8}\%[0-9]*\%'</p>
  </blockquote>
  
  <p>e.g. 13412432%10000%</p>
  
  <p>My query is</p>
  
  <pre><code>SELECT 
  report."barcode" SIMILAR TO '[0-9]{5,8}\%[0-9]*\%',
  (CASE report."barcode" WHEN (report."barcode" SIMILAR TO '[0-9]{5,8}\%[0-9]*\%') THEN 'match'
  ELSE 'noMatch'
  END) AS matchColumn
  FROM report
  </code></pre>
  
  <p>However I'm always getting this error</p>
  
  <blockquote>
    <p>ERROR:  operator does not exist: text = boolean
    LINE 3: (CASE report."barcode" WHEN (report."barcode...</p>
    
    <p>HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
    SQL state: 42883
    Character: 106</p>
  </blockquote>
  
  <p>I'm fairly new to SQL so when the docs says that it expects a true/false statement after WHEN I figured I could use the SIMIAR TO pattern matching since it returns boolean.</p>