Created
February 26, 2016 15:34
-
-
Save JDMcKinstry/eac8e69e123434993c20 to your computer and use it in GitHub Desktop.
Converts a String into an Array of Numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Object['defineProperty'] && !String.prototype.hasOwnProperty('toIntArry')) Object.defineProperty(String.prototype, "toIntArry", { | |
// b = split character/phrase | |
// c = boolean wether to keep periods or not | |
value: function(b, d) { | |
b || (b = ""); | |
var a = this.split(b), c; | |
for (c in a) a[c] = parseFloat(a[c].replace(d ? /[^0-9|.]/g : /[^0-9]/g, "").replace(/^0+/g, "")); | |
return a.filter(function(a) { return a === a }) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment