4

I understand that given a string str

str.replace(/\s/g,'');

will remove all spaces in a string.

How can I remove all characters that are not lower case letters from the string?

Thomas
  • 1,035
  • 5
  • 18
  • 33

1 Answers1

18

You could:

str.replace( /[^a-z]/g, '' );
Lucas
  • 12,877
  • 9
  • 67
  • 118