I have the following input elements:
This can be done like so:
$('input').filter(function(){ return this.id.match(/^AAA_.+_BBB$/) })
You can give use $('input', ) to make the search more precise. See also here
$('input', )