-1

How do I use replace regex in JavaScript to get rid of everything that's not a letter, number or space in a sentence?

var string = "here is a sentence with letters and numbers and symbols 123!@#";
Toto
  • 89,455
  • 62
  • 89
  • 125
frosty
  • 2,559
  • 8
  • 37
  • 73
  • 1
    Possible duplicate of [Remove all characters except alphanumeric and spaces with javascript](https://stackoverflow.com/questions/14640486/remove-all-characters-except-alphanumeric-and-spaces-with-javascript) – Ivar Jan 05 '19 at 01:16

1 Answers1

1

var string = "here is a sentence with letters and numbers and symbols 123!@#";

var x = string.replace(/[^a-zA-Z0-9 ]/g,'')
console.log(x)
vicatcu
  • 5,407
  • 7
  • 41
  • 65