title: Multiple replaces with predefined indexes
body: <p>This is for JavaScript specifically.</p>
  
  <p>Say I have a string, <code>"cat dog cat"</code>, and I must replace both characters 0-2 and 8-10 with <code>"1"</code> and characters 4-6 with <code>"2"</code>, resulting in <code>"1 2 1"</code>.</p>
  
  <p>I <em>only</em> know the ranges of what I have to replace - I do not know their content</p>
  
  <p>I know what I have to replace each range with, and I know the ranges to begin with, but if I replace the first range, the positions of everything else has shifted, meaning that any further replacements would affect the wrong indexes.</p>
  
  <p>How would I carry out this replacement correctly?</p>