Get non-numeric characters then number on each line of a block of texf

preg_match('/[^\d]+/', $string, $textMatch);
preg_match('/\d+/', $string, $numMatch);

$text = $textMatch[0];
$num = $numMatch[0];

Alternatively, you can use preg_match_all with capture groups to do it all in one shot:

preg_match_all('/^([^\d]+)(\d+)/', $string, $match);

$text = $match[1][0];
$num = $match[2][0];

Leave a Comment