treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Strip Numbers from a String

Last updated on:

var someString = "Hello 123 World!";

newString = someString.replace(/[0-9]/g, '');

// console.log(newString);
// "Hello  World!";
View Comments

Comments

  1. Permalink to comment#

    I don’t think I’ve ever use regex in javascript. Thanks for the reminder that you can!

  2. Permalink to comment#

    Thanks for this nice tip of using regex

  3. The same thing can be achieved with:

    var someString = “Hello 123 World!”;
    newString = someString.replace(/\d+/g, ”);

Leave a Comment

Use markdown or basic HTML and be nice.