You can combine both selectors in a multiple attribute selector.
$("[id^=AAA_][id$=_BBB]")
It will return all the elements that matches all the specified attribute filters:
[id^=AAA_]matches elements withidattribute starting withAAA_, and[id$=_BBB]matches elements withidattribute ending with_BBB.
Another generic alternatives:
- Using a custom
:regex()selector, - Using a
.filter()-based approach.