Skip to content

Commit

Permalink
Moved egrep function into its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
baphled committed Aug 5, 2010
1 parent 90cac35 commit 0e92ede
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions public/javascripts/jquery.egrep.js
@@ -0,0 +1,30 @@
/**
* Basic function to help with regular expressions within jQuery
*
* @author Yomi Colledge
*
*/
(function($) {
$.fn.egrep = function(pat) {
var out = [];
var textNodes = function(n) {
if (n.nodeType == Node.TEXT_NODE) {
var t = typeof pat == 'string' ?
n.nodeValue.indexOf(pat) != -1 :
pat.test(n.nodeValue);
if (t) {
out.push(n.parentNode);
}
}
else {
$.each(n.childNodes, function(a, b) {
textNodes(b);
});
}
};
return this.each(function() {
textNodes(this);
});

};
})(jQuery);

0 comments on commit 0e92ede

Please sign in to comment.