Added another layer for 1 char suffixes

This commit is contained in:
Andreas Kristiansen
2026-01-24 08:31:27 +01:00
parent 1e9fba9878
commit d5fc310ad1
2 changed files with 40 additions and 4 deletions

View File

@@ -195,6 +195,14 @@ class Dxcc {
return null; # exit, undef
}
if (preg_match('/^[0-9]{2,}$/', $c)) { # If suffix consists of two or more digits -> ignore suffix, To catch callsigns like VP8ADR/40
$c = null;
}
if (preg_match('/^[A-Z]{1}$/', ($c ?? ''))) { # If suffix consists of exactly one letter -> ignore suffix, To catch callsigns like LU7CC/E
$c = null;
}
# Depending on these values we have to determine the prefix.
# Following cases are possible:
#
@@ -280,8 +288,8 @@ class Dxcc {
$prefix = $matches[1];
} elseif (preg_match($this->noneadditions, $c)) {
return '';
} elseif (preg_match('/^\d\d+$/', $c)) { # more than 2 numbers -> ignore
if (!preg_match('/(.+\d)[A-Z]* /', $b, $matches)) {
} elseif (preg_match('/^\d\d+$/', $c)) { # more than 2 numbers -> ignore
if (!preg_match('/(.+\d)[A-Z]*/', $b, $matches)) {
$this->logError('preg_match failed for multi-digit case', [
'testcall' => $testcall,
'b' => $b,
@@ -303,7 +311,7 @@ class Dxcc {
$prefix = $c . "0";
}
}
} elseif (($a) && (preg_match($this->noneadditions, $c))) { # Case 2.1, X/CALL/X ie TF/DL2NWK/MM - DXCC none
} elseif (($a) && (preg_match($this->noneadditions, ($c ?? '')))) { # Case 2.1, X/CALL/X ie TF/DL2NWK/MM - DXCC none
return '';
} elseif ($a) {
# $a contains the prefix we want