- preg_match_all: documentation ( source)
- var_export: documentation ( source)
<?php
$tests = [
'This string s_0a1f2d4e3c10b is foo.',
's_1a23b456c789',
'b_9d9d9d9d9d',
's_1e2f3a4b'
];
foreach ($tests as $test) {
var_export(
preg_match_all(
'~(?:s_|\G(?!^)[a-z]+)\K\d+~',
$test,
$matches
)
? $matches[0]
: []
);
echo "\n---\n";
}