$re = '/[0-9]{1,5}/m';
$str = '6004
281
2812
89112
23
02891
7821
28199
96822
56615
44261
60928
72912
527
910
0011
11111';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php