Is there a way to use an input array of values as a way to replace different string occurrences in one go?
Say we have an input array of ['a', 'b', 'c', 'd'], and a replacement array of ['1', '2', '3', '4'].
Now if we were to do something like:
UPDATE table SET field=replace('a string to be replaced', input, replacement)
every a would get replaced with whatever is on the same index of replacement ('1'), every b replaced with the same index of replacement ('2'), etc, so field would then become '1 string to 2e repl12e4'.
(Using Postgres 9.4)
EDIT:
Another example, input is ['string', 'replaced'], replacement is ['cat', 'dog'], field would become 'a cat to be dog'
array_replace()