I think a simpler solution, rather than using preg_match, is to simply explode the string using " as the delimiter, where the ids will be the second element (index 1).
$string = '[gallery ids="2282,2301,2302,2304,2283,2303,2285,459,1263,469,471,1262,1261,472,608,467,607,606,466,460"]';
$array = explode('"', $string);
$ids = explode(',', $array[1]);
This can be quite elegant from PHP 5.4 where function array dereferencing has been added:
$string = '[gallery ids="2282,2301,2302,2304,2283,2303,2285,459,1263,469,471,1262,1261,472,608,467,607,606,466,460"]';
$ids = explode(',', explode('"', $string)[1]);
The benefit this has over preg_match is that it doesn't matter what the values are -- they could be numbers or letters or other symbols.
strpos+substrinstead?