string = string.substr(0, index) + val +
          string.substr(index + group.length, string.length);