You have another problem too. It's invalid for an identifier to start with a number.
Other than that, you can use \d instead of [0-9], and by matching /\d+/ you'll get an array of all groups of numbers. ['12345', '5']
var divID = '12345-5';
var matches = divID.match(/\\d+/);
var id2 = matches;
alert(id2); // alerts 5