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
Lets say you want to replace Kth index (0-based index) with 'Z'. You could use Regex to do this.
Kth
'Z'
Regex
var re = var re = new RegExp("((.){" + K + "})((.){1})") str.replace(re, "$1A$`");