Last active
May 20, 2016 22:04
-
-
Save gdibble/73821f9eef2d74084a2c to your computer and use it in GitHub Desktop.
Revisions
-
gdibble revised this gist
Oct 23, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -7,9 +7,9 @@ * @return {Numeric} -1 means not found */ if (typeof Array.prototype.reIndexOf === 'undefined') { Array.prototype.reIndexOf = function (str) { for (var i in this) { if (str.toString().match(this[i])) { return i; } } -
gdibble created this gist
Oct 23, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ /** * Regular Expresion IndexOf for Arrays * This little addition to the Array prototype will iterate over array * and return the index of the first element which matches the provided * regular expresion. Note: This will not match on objects. * @param {RegEx} rx The regular expression to test with. E.g. /-ba/gim * @return {Numeric} -1 means not found */ if (typeof Array.prototype.reIndexOf === 'undefined') { Array.prototype.reIndexOf = function (rx) { for (var i in this) { if (this[i].toString().match(rx)) { return i; } } return -1; }; }