title: Removing the first or last delimeter in a string SQL
body: <pre><code>create table addresses (address varchar(50));
  insert into addresses(address) values
  ('123 Pillage Road, EN45EX'),
  ('123 Pill,age Road, EN45EX'),
  ('123 Pillage Road, EN4,5EX');
  </code></pre>
  <p>and i'm trying to remove the first <code>,</code> delimiter and the last by:</p>
  <pre><code>update addresses 
  set address = 
          case address
                  when strpos(address, ',') &lt; 17 then regexp_replace(address, ',','')
                  when strpos(address, ',') &gt; 17 then REVERSE(regexp_replace(REVERSE(address), ',',''))
          end
  where char_length(address) - char_Length(replace(address,',','')) &gt; 1
  </code></pre>
  <p>This gives a</p>
  <pre><code>ERROR:  operator does not exist: character varying = boolean
  LINE 4:     when strpos(address, ',') &lt; 17 then regexp_replace(addre...
              ^
  </code></pre>
  <p>So Im finding the middle delimiter location (17) and trying to do a specific replace function on the delimiters found before and after. Where is the error coming from?</p>