How to return only named groups with preg_match or preg_match_all?

前端 未结 9 1416
余生分开走
余生分开走 2020-12-09 10:51

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(         


        
9条回答
  •  生来不讨喜
    2020-12-09 11:14

    I do not think you can make preg_* do it, but you can do it with a simple loop. But I don't see why those elements pose a problem.

提交回复
热议问题