Romanian regexes¶
Python regexes for Romanian identifiers, with checksum validation: CNP, CUI, ONRC trade register number, IBAN, ID card, passport, plates and phone numbers.
22 regexes, from regular_regexes/ro/regexes.json, called as rre.ro.<name>(text).
Personal numbers (1) · Identity documents (4) · Companies and tax (4) · 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.ro.cnp |
ro_cnp |
cnp¶
Romanian personal numeric code (CNP, cod numeric personal): 13 digits for sex and century, birth date, county and serial, like 5900101123454; only real dates and county codes.
rre.ro.cnp(text)
\b[1-9]\d{12}\b
Matches are checked with ro_cnp; one that fails it is dropped.
Identity documents¶
| function | checksum validator |
|---|---|
rre.ro.id_card_number |
|
rre.ro.mrz_id_card |
ro_mrz_id_card |
rre.ro.mrz_passport |
mrz_td3 |
rre.ro.passport_number |
id_card_number¶
Romanian identity card number (seria și numărul buletinului): a two-letter county series and six digits, with an optional nr. between them, like RX nr. 123456 or XB123456; only existing series.
rre.ro.id_card_number(text)
\b(?:A[BGRSXZ]|B[CHNRTVZ]|C[JLSTV]|D[BDJPRTXZ]|G[GJLRZ]|H[DR]|I[FLSZ]|K[LSTVXZ]|M[BHMSXZ]|N[TZ]|OT|P[HKX]|R[DKRTX]|S[BJLMRVXZ]|T[CLMRZ]|V[LNSX]|X[BCHMRTVZ]|Z[BCHLRSTV]),?\s?(?:(?i:nr\.?|num[aă]r(?:ul)?)\s?)?\d{6}\b
mrz_id_card¶
Machine-readable zone (MRZ) of a Romanian identity card: the electronic card's first line (ICAO TD1, IDROU...) or the second line of the older card's 36-character zone, with ROU.
rre.ro.mrz_id_card(text)
(?<![A-Z0-9<])(?:[IAC][A-Z<]ROU[A-Z0-9<]{25}|[A-Z0-9<]{9}\dROU\d{6}\d[MFX<]\d{6}\d[A-Z0-9<]{7}\d)(?![A-Z0-9<])
Matches are checked with ro_mrz_id_card; one that fails it is dropped.
mrz_passport¶
Machine-readable zone (MRZ) of a Romanian passport, second line (ICAO TD3): 44 characters with the passport number, ROU as nationality, date of birth, sex and expiry date.
rre.ro.mrz_passport(text)
(?<![A-Z0-9<])[A-Z0-9<]{9}\dROU\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¶
Romanian passport number (număr de pașaport) after pașaport or passport (with nr. or no.), keyword included in the match: eight or nine digits, like pașaport nr. 051234567.
rre.ro.passport_number(text)
\b(?i:pa[șşs]aport(?:ul)?|passport)(?:\s(?i:nr\.?|num[aă]r(?:ul)?|no\.?))?:?\s?\d{8,9}\b
Companies and tax¶
| function | checksum validator |
|---|---|
rre.ro.company_name |
|
rre.ro.cui |
ro_cui |
rre.ro.trade_register_number |
ro_onrc |
rre.ro.vat_number |
ro_cui |
company_name¶
Romanian company name: capitalized words, also in quotes, followed by S.R.L., SRL-D, S.A., S.N.C., S.C.S., S.C.A., PFA, I.I. or I.F., like S.C. Alfa Beta S.R.L., or PFA and the owner's name, like PFA Popescu Ion.
rre.ro.company_name(text)
(?<![\w&'.„”"-])[„"]?[A-ZĂÂÎȘŞȚŢ0-9][\w&'.„”"-]*(?:\s(?:[„"]?[A-ZĂÂÎȘŞȚŢ0-9][\w&'.„”"-]*|&)){0,6}\s(?:S\.?R\.?L\.?(?:-D)?|S\.?A\.?|S\.?N\.?C\.?|S\.?C\.?S\.?|S\.?C\.?A\.?|P\.?F\.?A\.?|I\.I\.|I\.F\.)(?!\w)|\bP\.?F\.?A\.?\s[A-ZĂÂÎȘŞȚŢ][\w-]+(?:\s[A-ZĂÂÎȘŞȚŢ][\w-]+){1,3}
cui¶
Romanian company tax code (CUI, CIF, cod fiscal) after its keyword, which is part of the match: up to ten digits, with or without RO, like CUI 12345674 or C.I.F.: RO 12345674.
rre.ro.cui(text)
\b(?:C\.?U\.?I|C\.?I\.?F|[Cc]od(?:ul)? fiscal)\.?:?\s?(?:RO\s?)?[1-9]\d{1,9}\b
Matches are checked with ro_cui; one that fails it is dropped.
trade_register_number¶
Romanian trade register number (număr de ordine în Registrul Comerțului, ONRC): the old form J40/1234/2020 or the 2024 one like J2025000001004, for the J, F and C registers.
rre.ro.trade_register_number(text)
\b[JFC]\s?\d{1,2}\s?/\s?\d{1,5}\s?/\s?(?:19|20)\d{2}\b|\b[JFC](?:199\d|20\d{2})\d{9}\b
Matches are checked with ro_onrc; one that fails it is dropped.
vat_number¶
Romanian VAT number (cod de TVA): RO and the CUI of six to ten digits, with or without a space, like RO12345674.
rre.ro.vat_number(text)
\bRO ?[1-9]\d{5,9}\b
Matches are checked with ro_cui; one that fails it is dropped.
Banking and payments¶
| function | checksum validator |
|---|---|
rre.ro.bic |
|
rre.ro.iban |
iban |
bic¶
BIC (SWIFT code) of a Romanian bank: four letters, RO and two letters or digits, with an optional three-character branch code, like RNCBROBU or BTRLRO22.
rre.ro.bic(text)
\b[A-Z]{4}RO[A-Z0-9]{2}(?:[A-Z0-9]{3})?\b
iban¶
Romanian IBAN: RO, two check digits, a four-letter bank code and 16 letters or digits, with or without spaces, like RO49 AAAA 1B31 0075 9384 0000.
rre.ro.iban(text)
\bRO\d{2} ?[A-Z]{4}(?: ?[A-Z0-9]{4}){4}\b
Matches are checked with iban; one that fails it is dropped.
Phones and SIM cards¶
| function | checksum validator |
|---|---|
rre.ro.iccid |
luhn |
rre.ro.imsi |
|
rre.ro.mobile_number |
phone |
rre.ro.msisdn |
phone |
rre.ro.phone_number |
phone |
rre.ro.premium_number |
phone |
iccid¶
SIM card number (ICCID) of a Romanian SIM: 8940 followed by 14 to 16 digits, without spaces, like 8940011234567890125.
rre.ro.iccid(text)
\b8940\d{14,16}\b
Matches are checked with luhn; one that fails it is dropped.
imsi¶
IMSI (subscriber identity on a SIM) of a Romanian network: mobile country code 226 and 12 more digits, 15 in all, like 226011234567890.
rre.ro.imsi(text)
\b226\d{12}\b
mobile_number¶
Romanian mobile number (număr de mobil): 07 and eight digits, or +40 or 0040 and 7, with spaces, dots, slashes or dashes, like 0722.123.456; only valid Romanian mobile numbers.
rre.ro.mobile_number(text)
(?:(?:\+|\b00)40[\s.-]?(?:\(0\)[\s.-]?)?|(?<![\w-])0)7\d\d(?:[\s./-]?\d){6}\b(?![ .-]\d{1,3}\b)
Matches are checked with phone (regions RO, kind mobile); one that fails it is dropped.
msisdn¶
Romanian mobile number in MSISDN form, as in telecom records: 40 and the number without its 0, 11 digits like 40722123456; only valid Romanian mobile numbers.
rre.ro.msisdn(text)
(?<!\+)\b407\d{8}\b
Matches are checked with phone (regions RO, kind msisdn); one that fails it is dropped.
phone_number¶
Romanian phone number (număr de telefon): 0 and nine digits, landlines like 021 123 4567 or (0264) 123 456 and 07 mobiles, also with +40 or 0040; only valid Romanian numbers.
rre.ro.phone_number(text)
(?:(?:\+|\b00)40[\s.-]?(?:\(0\)[\s.-]?)?|\(0|(?<![\w-])0)[237-9]\d(?:(?:[\s./-]|\)\s?)?\d){7}\b(?![ .-]\d{1,3}\b)
Matches are checked with phone (regions RO); one that fails it is dropped.
premium_number¶
Romanian premium-rate number: 090x and six digits, national or with +40 or 0040, like 0900 123 456; only valid Romanian numbers.
rre.ro.premium_number(text)
(?:(?:\+|\b00)40[\s.-]?(?:\(0\)[\s.-]?)?|(?<![\w-])0)90\d(?:[\s./-]?\d){6}\b(?![ .-]\d{1,3}\b)
Matches are checked with phone (regions RO, kind premium); one that fails it is dropped.
Places and addresses¶
| function | checksum validator |
|---|---|
rre.ro.postal_code_city |
|
rre.ro.street_address |
postal_code_city¶
Romanian postal code (cod poștal) and town: six digits and the place name, like 400001 Cluj-Napoca or 010011 București.
rre.ro.postal_code_city(text)
\b\d{6}\s(?!(?:RON|LEI|Lei|EUR|Euro|USD)\b)[A-ZĂÂÎȘŞȚŢ][A-Za-zĂÂÎȘŞȚŢăâîșşțţ-]+(?: [A-ZĂÂÎȘŞȚŢ][a-zăâîșşțţ][A-Za-zăâîșşțţ-]*){0,2}(?!\w)
street_address¶
Romanian street address (adresă): Str., Bd., Calea, Șos., Al., Piața, Splaiul or Intrarea, the name and number, with bl., sc., et. and ap. if given, like Calea Victoriei 155.
rre.ro.street_address(text)
(?<!et )\b(?i:str(?:\.|ada)|b(?:d\.|-dul|dul\.?|ulevardul)|calea|[șşs]os(?:\.|eaua)|al(?:\.|eea)|pia[țţt]a|splaiul|intrarea)\s?[A-ZĂÂÎȘŞȚŢ0-9][\w'.-]*(?:\s[\w'.-]+){0,4}?,?\s(?i:nr\.?\s?)?\d+[A-Za-z]?(?:-\d+[A-Za-z]?)?(?:,?\s(?i:bl|sc|et|ap)\.\s?[\w-]+)*
Vehicles, ships and parcels¶
| function | checksum validator |
|---|---|
rre.ro.aircraft_registration |
|
rre.ro.license_plate |
aircraft_registration¶
Romanian aircraft registration: YR- and three letters, like YR-ABC, four digits for gliders and ultralights, like YR-1234, or YR-D and four digits for drones.
rre.ro.aircraft_registration(text)
\bYR-(?:[A-Z]{3}|[1-9]\d{3}|D\d{4})\b
license_plate¶
Romanian license plate (număr de înmatriculare): county code, two digits and three letters, like CJ-12-XYZ, or B for Bucharest and two or three digits, like B 123 ABC.
rre.ro.license_plate(text)
\b(?:(?:A[BGR]|B[CHNRTVZ]|C[JLSTV]|D[BJ]|G[JLR]|H[DR]|I[FLS]|M[HMS]|NT|OT|PH|S[BJMV]|T[LMR]|V[LNS])[ -]?\d{2}|B[ -]?\d{2,3})[ -]?[A-HJ-NPR-Z][A-PR-Z]{2}\b
Justice and police¶
| function | checksum validator |
|---|---|
rre.ro.ecli |
ecli¶
European Case Law Identifier (ECLI) of a Romanian court decision: ECLI:RO:, the court, the year and the number, like ECLI:RO:JDS4B:2017:001.004053.
rre.ro.ecli(text)
\bECLI:RO:[A-Z0-9]+:\d{4}:[A-Z0-9.]*[A-Z0-9]