$re = '/DEV-123[0-9](?:\s+(?!DEV-123[0-9])\S+){0,5}/';
$str = 'This DEV-1231 story is about a man. He DEV-1232 is from DEV-1233 the USA. He is a university professor. He goes DEV-1234 to Nepal. He DEV-1235 climbs a mountain. The mountain is covered in ice. There is a hole in the ice. It is 22 metres deep. The man falls in it. DEV-1236 He doesn’t DEV-1237 go all the way down. He stops somewhere in the hole. He cannot move. His arm and five ribs are broken.';
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