Replace characters in javascript
Example :
var StringChar = "this is my 324o234u324t2342p234u234t"; //Your string to get replaced
In this case i need to remove the numbers and get the filtered output.
Replace Method in Javascript :
var ReplacedCharacters = String.replace("0123456789"," ");
Output : "this is my 324o234u324t2342p234u234t";
In this cases we can do like this :
var ReplacedChar = "";
var Characters = "";
var InValidChars = "0123456789";
for (d = 0; d < StringChar.length; d++) {
Characters = StringChar.charAt(d);
if (InValidChars.indexOf(Characters) == -1) {
ReplacedChar = ReplacedChar + Characters;
}
the resulting output is : ReplacedChar = this is my output
No comments:
Post a Comment