3v4l.org

run code in 300+ PHP versions simultaneously
<?php $regex = '/(?:\h*C\h+|\G(?!^))\h*,*\h*\K\d+/i'; $strings = [ "C 1,13,7,2,55", "c 1 , 12,15 , 8 , 9,10,11", "1,2 , 4,5", "d 12456, 9890" ]; foreach ($strings as $s) { if (preg_match_all($regex, $s, $matches)) { print_r($matches[0]); } }

preferences:
27.66 ms | 405 KiB | 5 Q