Will the regular expression pattern match all decimals, but the first? I am using javascript replace () and would like to remove everything except the first decimal number in a string.
Examples:
1.2.3.4.5 --> 1.2345 .2.3.4.5 --> .2345 1234.. --> 1234.
You can do something like this:
function parseAndNormalizeDecimal(dec) { var i = 0; var result = dec.replace(/\./g, function(all, match) { return i++===0 ? '.' : ''; }); return result; }