Skip to content

Instantly share code, notes, and snippets.

@sorz
Created Feb 18, 2014
Embed
What would you like to do?
function matchFloat(s) {
f = s.replace(/[^\d]+/g, '');
g = s.split(/\d/);
if (g.length == 0)
return f;
else if (g[0].contains('-'))
f = '-' + f;
for (var i=0; i<g.length - 1; i++)
if (g[i].contains('.'))
return f / (10 * Math.pow(10, g.length - i - 2));
return f;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment