Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (9.5k points)

Can anyone tell me how I can remove all special characters except space from a string using JavaScript?

1 Answer

0 votes
by (19.7k points)

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, ""));

Interested in Java? Check out this Java tutorial by Intellipaat.  

Related questions

Browse Categories

...