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
regonSupported Formats
- 9 digits:
NNNNNNNNN - 14 digits:
NNNNNNNNNNNNNN
FastPII validates both formats.
Validation Logic
- Require exactly 9 or 14 digits.
- Run the appropriate weighted Mod 11 checksum.
Checksum Algorithm (9-digit)
- Multiply each digit by weights
[8, 9, 2, 3, 4, 5, 6, 7]. - Sum the products.
- Take
sum % 11. - If the result is
10, the checksum digit is0. Otherwise, the result is the checksum digit. - Compare with the 9th digit.
Checksum Algorithm (14-digit)
- Multiply each digit by weights
[2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8]. - Sum the products.
- Take
sum % 11. - If the result is
10, the checksum digit is0. Otherwise, the result is the checksum digit. - Compare with the 14th digit.
Python Examples
Explicit Engine (Recommended)
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.