Snippets → JavaScript → Strip Numbers from a String Strip Numbers from a String Chris Coyier on Aug 30, 2012 var someString = "Hello 123 World!"; newString = someString.replace(/[0-9]/g, ''); // console.log(newString); // "Hello World!";
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, ”);