JSFiddle - React, Tailwind, and code Playground
JavaScript
String.prototype.sreplace = function(start, length, word) {
return this.replace(
new RegExp("^(.{" + start + "}).{" + length + "}"), "$1" + word);
};
var result = "This is a test string".sreplace(10, 4, "replacement");
document.write(result);