There is not really a way to do this if the variables are tracked separately. If you stored them in an object, you can loop through the object using
$.each(myObject, function (key, value) {
if (key.indexOf('sub-') === 0) {
// to do
}
});
You can do this with an array, and use
myArray[myArray.length] = value
as you are looping through the form. Then loop through the array at the end to get the values you need.