Back
Can anyone tell me how I can remove all special characters except space from a string using JavaScript?
You can use the string replace function with simple regex like below:
const str = "abc's test#s";console.log(str.replace(/[^a-zA-Z ]/g, ""));
const str = "abc's test#s";
console.log(str.replace(/[^a-zA-Z ]/g, ""));
Interested in Java? Check out this Java tutorial by Intellipaat.
31k questions
32.8k answers
501 comments
693 users