$re = '/(?:X-)?QSO:\s+([0-9]*)\s+(DG|RY|PH|CW|FM)\s+(\d\d\d\d-\d\d-\d\d)\s+(\d\d\d\d)\s+[A-Z0-9\/]{3,15}\s+(.*)\s*([A-Z0-9\/]{3,15})\s+(.*)\s{1,}[0|1]/m';
$str = 'QSO: 14312 PH 2023-10-29 2110 ZF2B 59 8 ZL2AJ 59 32 0';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php