Remove all characters but digits from string – JavaScript

The following regular expression will match for a single character not present in the range between 0 (ASCII 48) and 9 (ASCII 57) (case sensitive).

Meaning it will convert from Test123 to Test.

myString = myString.replace(/[^0-9]/g, '');

Reading material

One comment

Leave a Reply

Add <code> Some Code </code> by using this tags.