remove special characters from string using javascript 2021
Remove specific special characters from string JavaScript
let str = "Hello^# Friend/";
// Below code will replace special characters with space
str.replace(/[^a-zA-Z ]/g, ""); // "Hello Friend"
//You can remove Specific charaters
string = string.replace(/[&\/\\#,+()$~%.'":*?<>{}]/g, '');
Remove all Only allow alphabets
const str = "your's test#s";
console.log(str.replace(/[^a-zA-Z ]/g, " "));
Only allow letters and numbers
string = string.replace(/[^a-zA-Z0-9]/g, ''); // any special charaters will be replaced