Edit report at http://bugs.php.net/bug.php?id=54279&edit=1
ID: 54279 Updated by: fel...@php.net Reported by: donciprian at gmail dot com Summary: preg_grep does not recognize this regex '/[0-9]*$/' to filter numbers out -Status: Open +Status: Bogus Type: Bug Package: PCRE related Operating System: Ubuntu 10.10 PHP Version: 5.3SVN-2011-03-16 (SVN) Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php There is no bug here... preg_grep is not meant to return the group captured data separately... You need to use preg_match()/preg_match_all() for such. Previous Comments: ------------------------------------------------------------------------ [2011-03-16 23:26:42] donciprian at gmail dot com Description: ------------ I am trying to filter numbers from the end of a string in a array. i have a array full of these strings : $testArr = array('foto_1','foto_45'); $resArr = preg_grep('/[0-9]*$/',$testArr); and the $resArr array that gets returned from preg_grep, contains the same strings, i am looking for a array that contains just the numbers that were filtered using the regex Test script: --------------- <?php $testArr = array('foto_1','foto_45'); $resArr = preg_grep('/[0-9]*$/',$testArr); print_r($resArr); ?> Expected result: ---------------- to see a array full of the numbers what were at the end of the string in the input array something like this : Array ( [0] => 1 [1] => 45 ) Actual result: -------------- Array ( [0] => foto_1 [1] => foto_45 ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=54279&edit=1