const str = "jdk's example#s"; console.log(str.replace(/[^a-zA-Z ]/g, ""));
var str = "Pakainfo^# World/"; str.replace(/[^a-zA-Z ]/g, ""); // "Pakainfo World"
Example 2: js delete special characters
var desired = stringToReplace.replace(/[^\w\s]/gi, '')
delete all sign that is not a-b in string js
const str = "jdk's example#s"; console.log(str.replace(/[^a-zA-Z ]/g, " "));
Full Example using JS
<html> <head> <script> var str = "@!Welcome to our Pakainfo$$"; document.write(str); // Removing/deleting Special Characters document.write("<br>"+str.replace(/[^\w\s]/gi, '')); </script> </head> <body> </body> </html>
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.