Skip to content

Instantly share code, notes, and snippets.

@andyvanee
Created February 23, 2016 22:20
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 andyvanee/d6c171e59d63af1f6e84 to your computer and use it in GitHub Desktop.
Save andyvanee/d6c171e59d63af1f6e84 to your computer and use it in GitHub Desktop.
Select by matching an ID with a regex
// Select by matching id with a regex
// eg: $('select:regex("box.*-layout")')
jQuery.expr[':'].regex = function(elem, index, args) {
var regex = new RegExp(args[3], 'i');
return elem.id.match(regex);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment