Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
114
rated 0 times [  116] [ 2]  / answers: 1 / hits: 133873  / 14 Years ago, wed, march 31, 2010, 12:00:00

This works:



var.replace(/[^0-9]+/g, '');  


That simple snippet will replace anything that is not a number with nothing.



But decimals are real too. So, I'm trying to figure out how to include a period.



I'm sure it's really simple, but my tests aren't working.


More From » regex

 Answers
8

Simply: var.replace(/[^d.-]+/g, '');


[#97192] Sunday, March 28, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mckenna

Total Points: 445
Total Questions: 109
Total Answers: 109

Location: Virgin Islands (U.S.)
Member since Sun, May 16, 2021
3 Years ago
;