Javascript: strip out non-numeric characters from string?

I would use something very similar to what CMS posted. However, rather than manually complementing \d, I would use the built-in complement \D.

I would use something very similar to what CMS posted. However, rather than manually complementing \d, I would use the built-in complement \D. MyString = myString.

Replace(/\D/g,'').

– p. Campbell Dec 7 '09 at 19:55 1 This is my default regex reference: regular-expressions.Info/reference. Html The built-in character classes each have built-in complements.

\d \D (digits versus everything but digits) \w \W (word charcters versus everything but word characters) \s \S (whitespace versus everything but whitespace) – csj Dec 7 '09 at 20:38 Just to be clear, here is the syntax for replace: w3schools.Com/jsref/jsref_obj_regexp. Asp because the forward slashes and the "g" are part of that command, not part of the RegEx. – Mike at KBS Feb 9 at 0:17.

You can use a RegExp to replace all the non-digit characters: var myString = 'abc123.8'; myString = myString. Replace(/^\d/g, ''); // 1238.

Use a regular expression, if your script implementation supports them. Something like: myString. Replace(/^0-9/g, '').

Something along the lines of: yourString = yourString. Replace ( /^0-9/g, '' ).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions