Replace Char At Index Of String

[Solved] Replace Char At Index Of String | Swift - Code Explorer | yomemimo.com
Question : how to replace a character from a string from a index

Answered by : jatin-rajput

stra = 'Meatloaf'
posn = 5
nc = 'x'
stra = string[:posn] + nc + string[posn+1:]
print(stra)

Source : https://www.delftstack.com/howto/python/python-replace-character-in-string-at-index/ | Last Update : Tue, 27 Sep 22

Question : Replace Char At Index Of String

Answered by : eric-tam

function replaceAt(index, word, replacement)
{
let partOne = word.substring(0, index)
let partTwo = word.substring(index, word.length-1);
let answer = partOne + replacement + partTwo;
return answer;
}
var s = new String("AAAAA");
for(var i =0; i<s.length; i++)
{ if(s[i]=="A") {
s= replaceAt(i, s, "@@@@"); }
}
console.log(s);
/*console.log() @@@@@@@@@@@@@@@@@@@@*/

Source : | Last Update : Sun, 03 Jul 22

Answers related to replace char at index of string

Code Explorer Popular Question For Swift