var someString = "Hello 123 World!";
newString = someString.replace(/[0-9]/g, '');
// console.log(newString);
// "Hello World!";
Strip Numbers from a String
Chris Coyier
on
I don’t think I’ve ever use regex in javascript. Thanks for the reminder that you can!
Thanks for this nice tip of using regex
The same thing can be achieved with:
var someString = “Hello 123 World!”;
newString = someString.replace(/\d+/g, ”);