title: Replace character string elements by indices efficiently in R
body: <p>I would like to <strong>efficiently</strong> replace elements in my <code>character</code> object with other particular elements in particular places (these places are indices which I know as they are results of the <code>gregexpr</code> function). </p>
  
  <p>I would like some <code>foo</code> function that works like: </p>
  
  <pre><code>foo("qwerty", c(1,3,5), c("z", "x", "y"))
  </code></pre>
  
  <p>giving me: </p>
  
  <pre><code>[1] "zwxryy"
  </code></pre>
  
  <p>I searched the <code>stringr</code> package cran pdf but nothing hit my mind. Thank you in advance for any suggestions. </p>