$re = '/DE\s+(3[01]|[12]\d|[1-9])\s+DE/m';
$str = 'DE 1 DE
DE 2 DE
DE 3 DE
DE 4 DE
DE 5 DE
DE 6 DE
DE 7 DE
DE 8 DE
DE 9 DE
DE 10 DE
DE 11 DE
DE 12 DE
DE 13 DE
DE 14 DE
DE 15 DE
DE 16 DE
DE 17 DE
DE 18 DE
DE 19 DE
DE 20 DE
DE 21 DE
DE 22 DE
DE 23 DE
DE 24 DE
DE 25 DE
DE 26 DE
DE 27 DE
DE 28 DE
DE 29 DE
DE 30 DE
DE 31 DE
DE 32 DE
DE 0 DE
';
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