Validation + Extraction
Strict, full string matching into capture groups using PCRE syntax and producing a string array. Demo
preg_match(
'/^([a-z\d]{6})_([a-f\d]{32})_([a-f\d]{32})_(\d+)_(\d+)_(\d+)$/',
$string,
$m
);
Strict, full string matching into capture groups using POSIX syntax and producing a string array. Demo
preg_match(
'/^([[:alnum:]]{6})_([[:xdigit:]]{32})_([[:xdigit:]]{32})_([[:digit:]]+)_([[:digit:]]+)_([[:digit:]]+)$/',
$string,
$m
);
Matching by format returning the capture count and producing individual scalar variables (strings and integers). Demo
sscanf(
$string,
'%6[a-z0-9]_%32[a-f0-9]_%32[a-f0-9]_%d_%d_%d',
$one,
$two,
$three,
$four,
$five,
$six
);
Matching by format returning a scalar array (strings and integers). Demo
sscanf(
$string,
'%6[a-z0-9]_%32[a-f0-9]_%32[a-f0-9]_%d_%d_%d',
)
Text Extraction Only
Simple splitting on the delimiter without any validation and producing a string array: Demo
var_export(explode('_', $string));