DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Currency Formatted String To Number
Makes a currency-formatted string numeric
function currency2float(m){
var pattern = /[\.,][-|–]?$/; /* 100.-- >>> 100 */
/* 100,- >>> 100 */
var m = m.replace(pattern, "");
var pattern = /[\.,]([\d]{0,2})$/; /* 100,95 >>> 100X95 */
var m = m.replace(pattern, "X$1");
var pattern = /[\.',]/g; /* delete ' , . */
var m = m.replace(pattern, "");
var m = m.replace(/X/g, '.'); /* 100X95 >> 100.95 */
if(isNaN(m*1)) return false;
return(m*1);
}





