Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove all non-digit characters from a string jquery? [duplicate]

Possible Duplicate:
Javascript: strip out non-numeric characters from string

String matching is headache for me.

Example:

If I have strings like these:

abc123xyz456()*
^%$111u222

Then convert it to:

123456
111222
like image 727
Awan Avatar asked Dec 08 '10 13:12

Awan


1 Answers

How about regular expressions?

Try something something like:

'abc123xyz456()*'.replace(/\D/g,'') 
like image 100
ilivewithian Avatar answered Oct 21 '22 20:10

ilivewithian