Example:
$string = \"This is some text written on 2010-07-18.\"; preg_match(\'|(?\\d\\d\\d\\d-\\d\\d-\\d\\d)|i\', $string, $arr_result); print_r(
You could use T-Regx and go with group() or namedGroups() which only returns named capturing groups.
group()
namedGroups()
\d\d\d\d-\d\d-\d\d)', 'i')->match($subject)->first(function ($match) { $date = $match->get('date'); // 2010-07-18 $groups = $match->namedGroups(); // [ // 'date' => '2010-07-18' // ] });