Here’s a solution for selecting elements by ID and running a regex to filter the results:

$(’*[@id]’).filter(function() {
var regex = /^regularExpressionToMatchIdsAgainst/;
return ( $(this).attr(’id’).match(regex) !== null );
})