Solution for "js replace a part of a string with another string"

var str = "JavaScript replace method test"; var res = str.replace("test", "success"); //res = Javscript replace method success

javascript replace string

let string = 'soandso, my name is soandso'; let replaced = string.replace(/soandso/gi, 'Dylan'); console.log(replaced); //Dylan, my name is Dylan

how to use the replace method in javascript

Similar codes for "js replace a part of a string with another string"


Latest 'Javascript' questions

Added before "js replace a part of a string with another string"