Is there a standard function to remove the junk symbols in the text var a= "CWC%20-%20Maint%20Eng%20-%20El" which is instead to be displayed as CWC - Maint Eng - El
Asked
Active
Viewed 126 times
0
-
4Try `decodeURIComponent("CWC%20-%20Maint%20Eng%20-%20El");`. Search before you post. – 31piy Dec 06 '16 at 04:25
-
Please, edit your question and add the desired result – candlejack Dec 06 '16 at 04:27
-
@alessadro -- **CWC - Maint Eng - El** was the desired result. – 31piy Dec 06 '16 at 04:27
-
Then try the code in the 31piy's comment, is exact you need – candlejack Dec 06 '16 at 04:29
-
1Possible duplicate of [Javascript replace all "%20" with a space](http://stackoverflow.com/questions/20792572/javascript-replace-all-20-with-a-space) – Chris Nolet Dec 06 '16 at 06:41
1 Answers
0
you can use replace function, and make the string replace as a global, check here JsFiddle
var str = 'CWC%20-%20Maint%20Eng%20-%20El';
str = str.replace(/%20/g, " ");
console.log(str);
or you can use decodeURIComponent method
var str = 'CWC%20-%20Maint%20Eng%20-%20El';
var de_str = decodeURIComponent(str);
console.log(de_str);

nisar
- 1,055
- 2
- 11
- 26