3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_numerics ($str) { preg_match('/^mom_\d+/', $str, $matches); return $matches[0]; } $one = 'mom_5'; $two = 'mom_123'; $three = 'actions'; print_r(get_numerics($one)); print_r(get_numerics($two)); print_r(get_numerics($three));

preferences:
48.7 ms | 402 KiB | 5 Q