Skip to content

Instantly share code, notes, and snippets.

@juliocesar
Created September 10, 2009 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juliocesar/184370 to your computer and use it in GitHub Desktop.
Save juliocesar/184370 to your computer and use it in GitHub Desktop.
$.extend($.expr[':'], {
matches: function(e, i, m) {
if (!m[3]) return false;
var regexp = new RegExp(m[3], 'ig');
return regexp.test($(e).text());
}
})
// Usage:
// Say you have
// <p>Look ma</p>
// <p>No hands</p>
// You'd go $('p:matches(no)') and that would give you the second paragraph.
// Regex is case insensitive.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment