title: Positive Lookbehind in Postgres 9.5 using regexp_replace
body: <p>I have values like this: 1ST, 2ND, FIRST, and I want to remove the 'ST' and 'ND' ONLY if what comes before is a digit.  </p>
  
  <p>I am running postgres 9.5 and I have a <strong>positive lookbehind</strong> working in <a href="http://sqlfiddle.com/#!17/e415b/7" rel="nofollow noreferrer">SQL Fiddle</a> but it only works on 9.6</p>
  
  <pre><code>SELECT ex,
  regexp_replace(ex, '(?&lt;=[0-9]+)(TH|ST|ND|RD)', '', 'gi') as test 
  FROM t1
  </code></pre>
  
  <p>Is there any other way to do this besides using a CASE statement like this:</p>
  
  <pre><code>SELECT ex,
  (CASE WHEN ex ~ '\d(TH|ST|ND|RD)' THEN regexp_replace (ex, 'TH|ST|ND|RD', '','gi') ELSE ex end) as test_case
  FROM t1
  </code></pre>
  
  <p>Any suggestions would be appreciated. Thanks!</p>