replace string code example
Example 1: javascript replace string
var str = "JavaScript replace method test";
var res = str.replace("test", "success");
Example 2: javascript remove text from string
var str = "That is like so not cool, I was like totally mad.";
var cleanStr = str.replace(/like/g, "");
Example 3: javascript replace
var res = str.replace("find", "replace");
Example 4: string replace java
public static void main(String args[]){
String s1="my name is khan my name is java";
String replaceString=s1.replace("is","was");
System.out.println(replaceString);
}}
Example 5: javascript regex replace
const search = 'duck'
const replaceWith = 'goose';
const result = 'duck duck go'.replaceAll(search, replaceWith);
result;
Example 6: str replace javascript all
str.replace(/abc/g, '');