Skip to content

German regexes

Python regexes for German identifiers, with checksum validation: Steuer-ID, USt-IdNr, Rentenversicherungsnummer, Personalausweis, IBAN, Kennzeichen and phones.

23 regexes, from regular_regexes/de/regexes.json, called as rre.de.<name>(text).

Personal numbers (3) · Identity documents (4) · Companies and tax (3) · Banking and payments (2) · Phones and SIM cards (6) · Places and addresses (2) · Vehicles, ships and parcels (2) · Justice and police (1)

Personal numbers

function checksum validator
rre.de.health_insurance_number de_health_insurance_number
rre.de.pension_insurance_number de_pension_insurance_number
rre.de.tax_id de_tax_id

health_insurance_number

German health insurance number (Krankenversichertennummer, KVNR) as printed on the eGK card: a capital letter and nine digits, like A000500015.

rre.de.health_insurance_number(text)

\b[A-Z]\d{9}\b

Matches are checked with de_health_insurance_number; one that fails it is dropped.

pension_insurance_number

German pension insurance number (Rentenversicherungsnummer, Sozialversicherungsnummer): area number, birth date DDMMYY, a letter and three digits, like 15 070649 C 103; only existing area numbers.

rre.de.pension_insurance_number(text)

\b(?:0[2-489]|1\d|2[013-689]|3[89]|4[02-9]|[5-7]\d|8[0-29])\s?\d{6}\s?[A-Z]\s?\d{3}\b

Matches are checked with de_pension_insurance_number; one that fails it is dropped.

tax_id

German tax identification number (Steuer-IdNr, Steueridentifikationsnummer): 11 digits without a leading zero, together or grouped 2-3-3-3, like 86 095 742 719.

rre.de.tax_id(text)

\b[1-9]\d(?:\s?\d{3}){3}\b

Matches are checked with de_tax_id; one that fails it is dropped.

Identity documents

function checksum validator
rre.de.id_card_number
rre.de.mrz_id_card mrz_td1
rre.de.mrz_passport mrz_td3
rre.de.passport_number

id_card_number

German identity card number (Personalausweisnummer): nine letters and digits starting with L, M, N, P, R, T, V, W, X or Y, with at least one digit, like T22000129.

rre.de.id_card_number(text)

\b[LMNPRTVWXY](?=[A-Z]{0,7}\d)[0-9CFGHJKLMNPRTVWXYZ]{8}\b

mrz_id_card

Machine-readable zone (MRZ) of a German identity card or residence permit, first line (ICAO TD1): 30 characters with D<< as issuing country, like IDD<<T220001293<<<<<<<<<<<<<<<.

rre.de.mrz_id_card(text)

(?<![A-Z0-9<])[IAC][A-Z<]D<<[A-Z0-9<]{25}(?![A-Z0-9<])

Matches are checked with mrz_td1; one that fails it is dropped.

mrz_passport

Machine-readable zone (MRZ) of a German passport, second line (ICAO TD3): 44 characters with the passport number, D<< as nationality, date of birth, sex and expiry date.

rre.de.mrz_passport(text)

(?<![A-Z0-9<])[A-Z0-9<]{9}\dD<<\d{6}\d[MFX<]\d{6}\d[A-Z0-9<]{14}[\d<]\d(?![A-Z0-9<])

Matches are checked with mrz_td3; one that fails it is dropped.

passport_number

German passport number (Reisepassnummer): nine letters and digits starting with C, F, G, H, J or K, with at least one digit, like C01X00T47.

rre.de.passport_number(text)

\b[CFGHJK](?=[A-Z]{0,7}\d)[0-9CFGHJKLMNPRTVWXYZ]{8}\b

Companies and tax

function checksum validator
rre.de.company_name
rre.de.company_register_number
rre.de.vat_number de_vat_number

company_name

German company name: up to six capitalized words followed by a legal form such as GmbH, AG, KG, GmbH & Co. KG, OHG, SE, eG, GbR, UG (haftungsbeschränkt), e.K. or e.V., like Müller Bau GmbH.

rre.de.company_name(text)

\b(?!(?:D(?:ie|as|e[mnrs])|Eine?[mnrs]?|Firma|Fa\.|Beim?|Mit|Vo[mn]|Für|Laut|Und|Oder|Auch|Als|Seit|Nach|Gegen|Über|Unter|Durch|Ohne|Registergericht|Handelsregister)\s)(?:Dr\.|[A-ZÄÖÜ][\w&'-]{0,40})(?:\s(?:Co\.|Dr\.|[A-ZÄÖÜ0-9][\w&'-]{0,40}|&)){0,5}\s(?:(?:g?GmbH|AG|KGaA|KG|OHG|SE|eG|GbR|PartG(?:\smbB)?)\b|UG\b(?:\s\(haftungsbeschr(?:änkt|aenkt|\.)\))?|e\.\s?(?:K|Kfm|Kfr|V)\.)

company_register_number

German commercial register number (Handelsregisternummer): HRA, HRB or GnR and up to six digits, like HRB 12345 B, with the court before it when given (Amtsgericht München HRB 123456).

rre.de.company_register_number(text)

\b(?:(?:Amtsgericht|AG)\s[A-ZÄÖÜ][\w.-]{0,40}(?:\s(?:am|an\sder|im|i\.|\(?[A-ZÄÖÜ][\w.-]{0,40}\)?)){0,2},?\s)?(?:HR\s?[AB]|GnR)[\s-]?(?:Nr\.\s?)?[1-9]\d{0,5}\b(?![.,]\d)(?:\s(?!AG\b)[A-Z]{1,2}\b)?

vat_number

German VAT number (USt-IdNr, Umsatzsteuer-Identifikationsnummer): DE and nine digits, together or in groups of three, like DE123456788 or DE 123 456 788.

rre.de.vat_number(text)

\bDE\s?[1-9]\d{2}(?:\s?\d{3}){2}\b

Matches are checked with de_vat_number; one that fails it is dropped.

Banking and payments

function checksum validator
rre.de.bic
rre.de.iban iban

bic

BIC (SWIFT code) of a German bank: four letters, DE and two letters or digits, with an optional three-character branch code, like COBADEFFXXX or DEUTDEFF.

rre.de.bic(text)

\b[A-Z]{4}DE[A-Z0-9]{2}(?:[A-Z0-9]{3})?\b

iban

German IBAN: DE, two check digits and 18 digits, with or without spaces, like DE89 3704 0044 0532 0130 00.

rre.de.iban(text)

\bDE\d{2}(?: ?\d{4}){4} ?\d{2}\b

Matches are checked with iban; one that fails it is dropped.

Phones and SIM cards

function checksum validator
rre.de.iccid luhn
rre.de.imsi
rre.de.mobile_number phone
rre.de.msisdn phone
rre.de.phone_number phone
rre.de.premium_number phone

iccid

SIM card number (ICCID) of a German SIM: 8949 followed by 14 to 16 digits, without spaces, like 8949020000123456788.

rre.de.iccid(text)

\b8949\d{14,16}\b

Matches are checked with luhn; one that fails it is dropped.

imsi

IMSI (subscriber identity on a SIM) of a German network: mobile country code 262 and 12 more digits, 15 in all, like 262011234567890.

rre.de.imsi(text)

\b262\d{12}\b

mobile_number

German mobile number (Handynummer): 015x, 016x or 017x, national or with +49, 0049 or +49 (0), with spaces, slashes or dashes, like 0152 28817386; only valid German mobile numbers.

rre.de.mobile_number(text)

(?:(?:\+|\b00)49[\s-]?(?:\(0\)\s?|0)?|(?<!\d[\s/.-])\b0)1[5-7]\d(?:(?:\s?[/-]\s?|\s)?\d){7,8}\b(?![\s-]?\d)

Matches are checked with phone (regions DE, kind mobile); one that fails it is dropped.

msisdn

German mobile number in MSISDN form, as in telecom records: 49 and the number without its 0, 12 or 13 digits like 4915228817386; only valid German mobile numbers.

rre.de.msisdn(text)

(?<!\+)\b491[5-7]\d{8,9}\b

Matches are checked with phone (regions DE, kind msisdn); one that fails it is dropped.

phone_number

German phone number (Telefonnummer): 0 and the area code, +49, 0049 or +49 (0), or the area code in brackets like (030), with spaces, slashes or dashes after the area code, never inside it, like 030 23125000; only valid numbers.

rre.de.phone_number(text)

(?:(?:\+|\b00)49[\s-]?(?:\(0\)\s?|0)?|(?<!\d[\s/.-])\b0)(?:(?:[34]0|32|69|89)(?:(?:\s?[/-]\s?|\s)\d(?:(?:\s?[/-]\s?|\s)?\d){4,8}|\d{5,9})|(?!(?:[34]0|32|69|89))[1-9]\d\d(?:(?:\s?[/-]\s?|\s)?\d){4,8})\b(?![\s-]?\d)|\(0(?:(?:[34]0|32|69|89)|(?!(?:[34]0|32|69|89))[1-9]\d{2,4})\)\s?\d(?:(?:\s?[/-]\s?|\s)?\d){2,8}\b(?![\s-]?\d)

Matches are checked with phone (regions DE); one that fails it is dropped.

premium_number

German premium-rate (0900), service (0180) or televoting (0137) number: the prefix and seven digits, national or with +49, like 0900 5 123456; only valid German numbers.

rre.de.premium_number(text)

(?:(?:\+|\b00)49[\s-]?(?:\(0\)\s?|0)?|(?<!\d[\s/.-])\b0)(?:900|137|180)(?:(?:\s?[/-]\s?|\s)?\d){7}\b(?![\s-]?\d)

Matches are checked with phone (regions DE, kind premium); one that fails it is dropped.

Places and addresses

function checksum validator
rre.de.postal_code_city
rre.de.street_address

postal_code_city

German postal code (Postleitzahl, PLZ) and town: five digits, optionally after D-, and the place name, like 10115 Berlin, 60311 Frankfurt am Main or D-06108 Halle (Saale).

rre.de.postal_code_city(text)

\b(?:D-)?(?:0[1-9]|[1-9]\d)\d{3}\s(?!(?:Euro|EUR|Dollar|Franken|Mal|Stück|Leute|Personen|Fans|Punkte|Fälle|(?:Jahr|Tag)en?|(?:Mensch|Kund|Stimm|Wohnung|Fäll|Stund)en|(?:Einwohn|Mitarbeit|Besuch|Teilnehm|Zuschau|Nutz|Follow|Kilomet|Met)er)\b)(?:(?:Bad|St\.|Sankt)\s)?[A-ZÄÖÜ][a-zäöüß]+(?:-[A-ZÄÖÜ][a-zäöüß]+)*(?:\s(?:am|im|(?:an|ob|in)\sder)\s[A-ZÄÖÜ][a-zäöüß]+|\s\([A-ZÄÖÜ][a-zäöüß]+\))?

street_address

German street and house number (Straße, Hausnummer): a name ending in -straße, -str., -weg, -platz, -allee, -gasse, -ring, -damm or -ufer, or like Am Markt 3, with numbers like 12a or 5-7.

rre.de.street_address(text)

\b(?:(?!(?:Park|Stell|Sitz|Steh|Arbeits|Tabellen|Listen|Lager)platz)[A-ZÄÖÜ][\w-]{1,40}(?:[sS]tr(?:aße|asse|\.)|[wW]eg|[pP]latz|[aA]llee|[gG]asse|[rR]ing|[dD]amm|[uU]fer|[cC]haussee)|(?:[AI]m|An\sder|Auf\sdem|Zu[mr]|Alte|Neue|Lange|Hohe|[A-ZÄÖÜ][\w-]{1,40}er)\s(?:Str(?:aße|asse|\.)|Weg|Platz|Allee|Gasse|Ring|Damm|Ufer|Chaussee|Markt))\s?\d{1,3}(?:\s?[a-zA-Z])?\b(?:\s?[-/]\s?\d{1,3}(?:\s?[a-zA-Z])?\b)?

Vehicles, ships and parcels

function checksum validator
rre.de.aircraft_registration
rre.de.license_plate

aircraft_registration

German aircraft registration (Luftfahrzeugkennzeichen): D- followed by four letters, like D-AIMA or D-EABC.

rre.de.aircraft_registration(text)

\bD-[A-Z]{4}\b

license_plate

German license plate (Kfz-Kennzeichen): district code of one to three letters, one or two letters and one to four digits, eight characters at most, with an optional E or H, like B-MW 1234 or HH-XY 99E.

rre.de.license_plate(text)

\b(?!VW[- ]|[A-ZÄÖÜ]{3}[- ][A-Z]{2}[- ]\d{4})[A-ZÄÖÜ]{1,3}[- ][A-Z]{1,2}[- ][1-9]\d{0,3}[EH]?\b

Justice and police

function checksum validator
rre.de.ecli

ecli

European Case Law Identifier (ECLI) of a German court decision: ECLI:DE:, the court, the year and the number, like ECLI:DE:BGH:2017:290317UIXZR86.16.0.

rre.de.ecli(text)

\bECLI:DE:[A-Za-z0-9]+:\d{4}:[A-Za-z0-9.]*[A-Za-z0-9]