code: function replaceComplete(text, re, fnc) {
      var doNext = true,
        reg = new RegExp(re); // safe (not literal)
      function fncWrap() {
        doNext = true;
        return fnc.apply(null, arguments);
      }
      // This is faster than using RegExp#exec() and RegExp#lastIndex,
      // because replace() isn't called more than twice in almost all cases.
      while (doNext) {
        doNext = false;
        text = text.replace(reg, fncWrap);
      }
      return text;
    }
docs: Redo String#replace until target is not found