Regex: remove specific types of characters from string
11 March 2022 (Updated 28 August 2022)
Suppose you want to remove any character that is not a letter or a space. Here’s one approach:
function removeChars(str) {
return str.replace(/[^a-zA-Z\s]/g, '')
}
Tagged:
Regex
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment