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