Javascript Regular Expressions - Replace non-numeric characters

Posted by user271619 on Stack Overflow See other posts from Stack Overflow or by user271619
Published on 2010-03-31T17:23:42Z Indexed on 2010/03/31 17:33 UTC
Read the original article Hit count: 413

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about replace