I have this JS
var link ="#step-2";
What i need is to get new string that will be like this
var newlink = "STEP 2";
I hope this is simple solution using jquery?
You don't want to trim (trim(), and $.trim(), removes the leading, and trailing, white-space from a string, not special, or otherwise-identified, characters) the string; you need, instead, to use replace():
var link ="#step-2",
newlink = link.toUpperCase().replace(/[#-]/g, function (a){
return a === '#' ? '' : ' ';
});
trimming.replace()method to change the characters you don't want into characters you want to see. You can either do this by a simple replace or regular expresssion replace.