JavaScript Remove Special Characters from a String

Hello devs, today we're going to remove special characters from a string. Sometimes we need to extract the special characters from any string, and todays tutorial is about that. So, let's see how we can easily remove special characters from any string.

Removing Special Characters

 Let's see the below source code:

<!DOCTYPE html>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Remove Special Chracter from a String</title>
    myString = "Hi, shouts$%#dev@@@";
    newString = myString.replace(/[^\w\s]/gi, '');

And it'll produce the below result:

String After Removing Special Character 

That's it for today. I hope you've enjoyed this tutorial. Thanks for reading. ๐Ÿ™‚