Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved egrep function into its own file
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |