rghome
0
Q:

javascript remove character from string

str=str.slice(0, -1);
9
var str = "That is like so not cool, I was like totally mad.";
var cleanStr = str.replace(/like/g, "");//replace every "like" with blank ""
3
//replaces the first occurence only.
string.replace('characterToReplace', '');
or 
// first parameter is regular expression and g is global prop, replaces all occurences.
string.replace('/regex/g','');
7
mystring.replace(/r/g, '')
3
var str = "qwertyXuiop";

// We will remove the uppercase X from qwertyuiop,
// You can also use Regular Expressions, if you wish
var rm = str.replace('X', '');

// Check it
console.log(rm);
2

var str = "Visit Microsoft!";

var res = str.replace("Microsoft", "W3Schools");
 
8
var str = "Visit Microsoft!";

var res = str.replace("Microsoft", "W3Schools");
 
0

New to Communities?

Join the community