When I trigger a paste event in an input field, I have a method that replaces all special characters. However, it is also removing empty spaces between words. How can I prevent this from happening?
checkSpecialCharacters(){
let value = this.form.get("quantity").value.replace(/[^a-zA-Z0-9 ]/g,'').replace(/\s/g,'');
// if value = "testing value"
console.log(value) // returns testingvalue
}
What am I doing wrong here? Does [^a-zA-Z0-9 ]
including a space not skip spaces?