Skip to content

Instantly share code, notes, and snippets.

@JoshuaCarroll
Last active October 24, 2025 00:20
Show Gist options
  • Select an option

  • Save JoshuaCarroll/f6b2c64992dfe23feed49a117f5d1a43 to your computer and use it in GitHub Desktop.

Select an option

Save JoshuaCarroll/f6b2c64992dfe23feed49a117f5d1a43 to your computer and use it in GitHub Desktop.
Regular expression (regex) for non-US amateur radio call signs
All amateur radio call signs:
[a-zA-Z0-9]{1,3}[0-9][a-zA-Z0-9]{0,3}[a-zA-Z]
Non-US call signs:
\b(?!K)(?!k)(?!N)(?!n)(?!W)(?!w)(?!A[A-L])(?!a[a-l])[a-zA-Z0-9][a-zA-Z0-9]?[a-zA-Z0-9]?[0-9][a-zA-Z0-9][a-zA-Z0-9]?[a-zA-Z0-9]?[a-zA-Z0-9]?\b
US call signs:
^[AKNW][A-Z]{0,2}[0-9][A-Z]{1,3}$
@KudzuKid
Copy link

I prefer my own (no offense, please!), it seems to be ITU compliant from what I can tell, allowing only valid prefixes, etc. I might expect a little pushback for this, but this should catch most current (as of 10/2025) legit blocks. I haven't seen it fail, I've tried it on a few international calls, but 99% of what I deal with is scrapping U.S. calls from Netlogger AIM windows, etc. I've tested it with above-average success in a large ball of Lorem Ipsum. I embedded many callsigns and it didn't get fooled by tangled calls+text, e.g.:

Note

See the following examples for a known exception (for better or worse!). There may be (probably are) others... But this serves my purposes. Modify to your liking!

WILL NOT find n5abc in:
montes, nascetur ridiculus mus. Morbi placerat sem arcu, fermentum aliquam ligula imperdiet vitae. Nulla ac quam sed risus dignissim cursus ut non ipsum. Etiam mauris justo, semper vitae lacus id, efficitur fringilla ex. Integer aliquet non justo ut semper. n5abcPraesent ut attis orci. Curabitur justo enim, dictum quis est non, vulputate sollicitudin tellus. Integer eget justo in nisi porta egestas sagittis vel quam. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur a nulla lobortis, egestas sem sed, suscipit neque.
(Etc.)

But WILL find it n5abc in:
montes, nascetur ridiculus mus. Morbi placerat sem arcu, fermentum aliquam ligula imperdiet vitae. Nulla ac quam sed risus dignissim cursus ut non ipsum. Etiam mauris justo, semper vitae lacus id, efficitur fringilla ex. Integer aliquet non justo ut semper. n5abc Praesent ut attis orci. Curabitur justo enim, dictum quis est non, vulputate sollicitudin tellus. Integer eget justo in nisi porta egestas sagittis vel quam. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur a nulla lobortis, egestas sem sed, suscipit neque. (Etc.)

\b(?:
  A(?:A-L|M-O|P-S|X|Y|Z)|
  B(?:A-Z)?|
  C(?:A-Z)?|
  D(?:A-Z)?|
  E(?:2|3|4|5|6|7|8|9|A-Z)?|
  F(?:A-Z)?|
  G(?:A-Z)?|
  H(?:2|3|4|6|8|9|A-Z)?|
  I(?:A-Z)?|
  J(?:A-Z)?|
  K|
  L(?:A-Z)?|
  M|
  N|
  O(?:A-Z)?|
  P(?:2|3|4|5|6|7|8|9|A-Z)?|
  R|
  S(?:A-Z)?|
  T(?:2|3|4|5|6|7|8|9|A-Z)?|
  U(?:A-Z)?|
  V(?:A-Z)?|
  W|
  X(?:A-Z)?|
  Y(?:A-Z)?|
  Z(?:2|3|4|5|6|7|8|9|A-Z)?
)\d[A-Z]{1,4}\b

Tip

So why didn’t I just paste a 100% exhaustive one-liner?

The ITU allocation table is pretty big and includes ranges that I believe are best represented as compact ranges (e.g., AA–AL, JA–JS, VK–VN), plus lots of numeric/alpha mixes. I compressed those ranges above into compact patterns so the final regex remains maintainable. The underlying authoritative source is the ITU table (Appendix 42) — you can fetch the latest on your own if this is stale data when you read it!

But if your engine doesn't support the x/free-spacing mode, try this:

\b(?:A(?:A-L|M-O|P-S|X|Y|Z)|B(?:A-Z)?|C(?:A-Z)?|D(?:A-Z)?|E(?:2|3|4|5|6|7|8|9|A-Z)?|F(?:A-Z)?|G(?:A-Z)?|H(?:2|3|4|6|8|9|A-Z)?|I(?:A-Z)?|J(?:A-Z)?|K|L(?:A-Z)?|M|N|O(?:A-Z)?|P(?:2|3|4|5|6|7|8|9|A-Z)?|R|S(?:A-Z)?|T(?:2|3|4|5|6|7|8|9|A-Z)?|U(?:A-Z)?|V(?:A-Z)?|W|X(?:A-Z)?| Y(?:A-Z)?|Z(?:2|3|4|5|6|7|8|9|A-Z)?)\d[A-Z]{1,4}\b

Caution

Any of this may eat your furniture at night and terrorize your dog. It will also dump a 55-gallon drum of "Temptations" for your cats. 73!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment