k0swe / dxcc-json

JSON reference for amateur radio DXCC entities
Apache License 2.0
24 stars 6 forks source link

Regex, European Russia, Asiatic Russia #8

Open PD5DJ opened 1 day ago

PD5DJ commented 1 day ago

I am working on a python based logbook. The dxcc lookup is based on dxcc.json

Only I experience some Regex issues with European Russia and Asiatic Russia.

For example with: RV9AL

Filtering out R?8, R?9 and R?0 seams to be not possible with "prefix" & "prefixRegex"

Prefix and Regex of Asiatic Russia: "prefix": "UA0,UA8,UA9,UB0,UB8,UB9,UC0,UC8,UC9,UD0,UD8,UD9,UE0,UE8,UE9,UF0,UF8,UF9,UG0,UG8,UG9,UH0,UH8,UH9,UI0,UI8,UI9,RA,RB,RC,RD,RE,RF,RG,RH,RI,RJ,RK,RL,RM,RN,RO,RP,RQ,RR,RS,RT,RU,RV,RW,RX,RY,RZ", "prefixRegex": "^(U[A-I][089]|R[A-Z])[A-Z0-9/]*$",

Prefix and Regex of European Russia: "prefix": "UA1,UA2,UA3,UA4,UA5,UA6,UA7,UB1,UB2,UB3,UB4,UB5,UB6,UB7,UC1,UC2,UC3,UC4,UC5,UC6,UC7,UD1,UD2,UD3,UD4,UD5,UD6,UD7,UE1,UE2,UE3,UE4,UE5,UE6,UE7,UF1,UF2,UF3,UF4,UF5,UF6,UF7,UG1,UG2,UG3,UG4,UG5,UG6,UG7,UH1,UH2,UH3,UH4,UH5,UH6,UH7,UI1,UI2,UI3,UI4,UI5,UI6,UI7,RA,RB,RC,RD,RE,RF,RG,RH,RI,RJ,RK,RL,RM,RN,RO,RP,RQ,RR,RS,RT,RU,RV,RW,RX,RY,RZ", "prefixRegex": "^(U[A-I][1-7]|R[1-8])[A-Z0-8/]*$",

The problem lies in that both json records contain almost the same "prefixes", "RV"

Als when I try regex ^(U[A-I][089]|R[A-Z])[A-Z0-9/]*$ on https://regexr.com/ I get a pass on all RV1 to RV7

a better regex should be: ^(U[A-I][089]|R[A-Z])[089/]*$

But still both prefixes keep conflicting.

PD5DJ commented 1 day ago

Ok, as soon as i Wrote my issue I think I got a fix.

Both Regex'es should be adjusted.

Asiatic Russia: "prefixRegex": "^(U[A-I][089]|R[A-Z089])[A-Z089/]$", European Russia: "prefixRegex": "^(U[A-I][1-7]|R[A-Z0-7])[A-Z0-7/]$",

xylo04 commented 1 day ago

Thanks for the suggestion, @PD5DJ! How does #9 look?

xylo04 commented 1 day ago

Oh, you've opened #10, thanks! I've changed #9 to just add regex verification to the python script. Rebase #10 on #9 and I'll review yours.