regex keep only alphanumeric and spaces code example Example: how to get only alphanumeric and whitespace in string regex /[A-Za-z\d\s]/g