FastPII Docs
Detectors

REGON

Detect and validate Polish business registry numbers with weighted Mod 11 checksum for 9-digit and 14-digit variants.

Purpose

Use the regon detector for Polish business registry numbers (REGON — Rejestr Gospodarki Narodowej).

Detector Name

regon

Supported Formats

  • 9 digits: NNNNNNNNN
  • 14 digits: NNNNNNNNNNNNNN

FastPII validates both formats.

Validation Logic

  1. Require exactly 9 or 14 digits.
  2. Run the appropriate weighted Mod 11 checksum.

Checksum Algorithm (9-digit)

  1. Multiply each digit by weights [8, 9, 2, 3, 4, 5, 6, 7].
  2. Sum the products.
  3. Take sum % 11.
  4. If the result is 10, the checksum digit is 0. Otherwise, the result is the checksum digit.
  5. Compare with the 9th digit.

Checksum Algorithm (14-digit)

  1. Multiply each digit by weights [2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8].
  2. Sum the products.
  3. Take sum % 11.
  4. If the result is 10, the checksum digit is 0. Otherwise, the result is the checksum digit.
  5. Compare with the 14th digit.

Python Examples

from fastpii import FastPII
from fastpii.countries.pl import PolishPack

priority = {"regon": 90, "pesel": 100, "email": 70, "name": 50}
engine = FastPII(priority=priority)
engine.register(PolishPack())
result = engine.detect("REGON: 123456785", detector_names=["regon"])

Convenience API

from fastpii import PrivacyGuard

guard = PrivacyGuard(regions=["pl"])
result = guard.validate("123456785", "regon")

print(result.is_valid)

Convenience API — Detect in free text

from fastpii import PrivacyGuard

guard = PrivacyGuard(regions=["pl"])
result = guard.detect("REGON: 123456785")

for finding in result.findings:
    print(finding.type, finding.value)

Limitations

  • REGON is specific to Polish business registry numbers.
  • The 9-digit and 14-digit formats have different checksum algorithms.

On this page