i having a string variable
var text = "hello hw r u";
And i need to replace 'h' to '*' and 'l' to '-'
hw to do that..
i having a string variable
var text = "hello hw r u";
And i need to replace 'h' to '*' and 'l' to '-'
hw to do that..
text = text.replace(/h/g, "*").replace(/l/g, "-");
In answer to you comment below
*
is a special character in a Reqular Expression pattern, you need to escape it using a backslash (\
) character. So it would be
replace(/\*/g, 'o')