title: Oracle regexp_replace on complete words
body: <p>I want to replace instances of the word OF with "OF". I only want this to work on complete words. So not on L_OF, DOF, OFZ, DOFD, OF_L, etc. </p>
  
  <p>My code works below except for the final string. </p>
  
  <p>It returns: </p>
  
  <pre><code>("OF"*OF + 2) 
  </code></pre>
  
  <p>... instead of: </p>
  
  <pre><code>("OF"*"OF" + 2) 
  </code></pre>
  
  <p>How can I get it to work on that one as well?</p>
  
  <pre><code>with stg as
  (
  select '(ofof+ol)' str from dual union all
  select '(oof+ol+of)'   from dual union all
  select '(*of + 2)'     from dual union all
  select '(of*of + 2)'   from dual 
  )
  select str,
         regexp_replace(upper(str), '(\W|^)(OF)(\W|$)', '\1"OF"\3') as str2
  from   stg
  </code></pre>