Assuming you donβt have millions of elements that start with βmine,β you can do:
$('[id^=my]').filter(function() { return this.id.matches(/\d/) && this.id.length == 3 })
This captures all elements that have an id starting with "my", contains a number and is only 3 characters long (so "my54" will not match, but "my6" will be)
source share