$re = '/Задача #(\d+)(?: - Параметр ([a-z\-0-9]+): (\d+:\d+))?/mi';
$str = '{Задача #1 - Параметр ZH-11: 03:00}
{Задача #2 - Параметр ZH-12: 04:00}
{Задача #3 - Параметр ZH-13: 05:00}
{Задача #4 - Парам етр ZH-14: 06:00}
{Задача #5 - Параметр ZH-15: 07:00}
{Задача #6 - Параметр ZH-16: 08:00}
Задача #7 - Параметр
Задача #8 -текст';
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