In postgresql I would like to substitute just in full words and not substrings. I noticed that replace and translate replace strings even in substrings. Then, I used regexp_replace to add the following:
SELECT REGEXP_REPLACE (UPPER('BIG CATDOG'), '(^|[^a-z0-9])' || UPPER('CAT') || '($|[^a-z0-9])', '\1' || UPPER('GATO') || '\2','g')
In the previous sample, CAT should not been replaced because it is not a whole word, but a substring which is part of a word. How can I achieve to avoid the replacement? The output should be BIG CATDOG because no substitution was possible.
Thanks