I have a string, let\'s say Hello world and I need to replace the char at index 3. How can I replace a char by specifying a index?
Hello world
var str = \"h
this is easily achievable with RegExp!
const str = 'Hello RegEx!'; const index = 11; const replaceWith = 'p'; //'Hello RegEx!'.replace(/^(.{11})(.)/, `$1p`); str.replace(new RegExp(`^(.{${ index }})(.)`), `$1${ replaceWith }`); //< "Hello RegExp"