French regexes¶
Python regexes for French identifiers, with checksum validation: NIR (sécurité sociale), SIREN, SIRET, TVA, numéro fiscal, IBAN, RIB, CNI, plates and phones.
23 regexes, from regular_regexes/fr/regexes.json, called as rre.fr.<name>(text).
Personal numbers (2) · Identity documents (4) · Companies and tax (4) · Banking and payments (3) · Phones and SIM cards (5) · Places and addresses (2) · Vehicles, ships and parcels (2) · Justice and police (1)
Personal numbers¶
| function | checksum validator |
|---|---|
rre.fr.nir |
fr_nir |
rre.fr.numero_fiscal |
fr_numero_fiscal |
nir¶
French social security number (NIR, numéro de sécurité sociale): 15 digits starting with 1 or 2 (7 or 8 for a temporary NIA), with 2A or 2B for Corsica, like 1 85 07 75 000 000 80.
rre.fr.nir(text)
\b[1278]\s?\d{2}\s?\d{2}\s?(?:\d{2}|2[AB])\s?\d{3}\s?\d{3}\s?\d{2}\b
Matches are checked with fr_nir; one that fails it is dropped.
numero_fiscal¶
French personal tax number (numéro fiscal, SPI): 13 digits starting with 0 to 3, spaced like 30 23 217 600 053 or written together.
rre.fr.numero_fiscal(text)
\b[0-3]\d\s?\d{2}\s?\d{3}\s?\d{3}\s?\d{3}\b
Matches are checked with fr_numero_fiscal; one that fails it is dropped.
Identity documents¶
| function | checksum validator |
|---|---|
rre.fr.id_card_number |
|
rre.fr.mrz_id_card |
fr_mrz_id_card |
rre.fr.mrz_passport |
mrz_td3 |
rre.fr.passport_number |
id_card_number¶
French identity card number (carte nationale d'identité, CNI): the 2021 card's nine letters and digits, like X4RTBPFW4 (not as a folder in a URL or after @), or the old card's 12 digits after CNI or carte d'identité, keyword included.
rre.fr.id_card_number(text)
\b(?:CNI\b|(?i:carte\s(?:nationale\s)?d['’]identit[ée]))\s?:?\s?(?:(?i:n[°o]|num[ée]ro)\.?\s?:?\s?)?\d{12}\b|(?<![/@])\b(?=\d*[A-Z])(?=[A-Z]*\d)[A-Z\d]{9}\b(?!/)
mrz_id_card¶
Machine-readable zone (MRZ) of a French identity card: the 2021 card's first line (ICAO TD1, IDFRA..., 30 characters) or the old card's second line of 36 (card number, first name, birth date).
rre.fr.mrz_id_card(text)
(?<![A-Z0-9<])(?:[IAC][A-Z<]FRA[A-Z0-9<]{25}|\d{4}[A-Z0-9]{3}\d{6}[A-Z<]{14}\d{7}[MF]\d)(?![A-Z0-9<])
Matches are checked with fr_mrz_id_card; one that fails it is dropped.
mrz_passport¶
Machine-readable zone (MRZ) of a French passport, second line (ICAO TD3): 44 characters with the passport number, FRA as nationality, date of birth, sex and expiry date.
rre.fr.mrz_passport(text)
(?<![A-Z0-9<])[A-Z0-9<]{9}\dFRA\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¶
French passport number (numéro de passeport): two digits, two capital letters and five digits, nine characters like 00AA00000.
rre.fr.passport_number(text)
\b\d{2}[A-Z]{2}\d{5}\b
Companies and tax¶
| function | checksum validator |
|---|---|
rre.fr.company_name |
|
rre.fr.siren |
luhn |
rre.fr.siret |
fr_siret |
rre.fr.vat_number |
fr_vat_number |
company_name¶
French company name (raison sociale) with its legal form after or before it, on one line: SARL, SAS, SASU, SA, EURL, SCI, SNC, SCP, SELARL, GIE, GAEC, EARL or EI, like Dupont SAS or SCI Les Lilas.
rre.fr.company_name(text)
\b(?:[A-ZÉÎ][\w&'’-]{0,40}(?: (?:(?:de|du|des|la|le|les|&) |[dl]['’]){0,2}[A-ZÉÎ][\w&'’-]{0,40}){0,3} (?:SASU|SAS|SARL|SA|EURL|SCI|SNC|SCP|SELARL|SELAS|GIE|GAEC|EARL|SCEA|EI)|(?:SASU|SAS|SARL|EURL|SCI|SNC|SCP|SELARL|SELAS|GIE|GAEC|EARL|SCEA) (?:(?:de|du|des|la|le|les|&) |[dl]['’]){0,2}[A-ZÉÎ][\w&'’-]{0,40}(?: (?:(?:de|du|des|la|le|les|&) |[dl]['’]){0,2}[A-ZÉÎ][\w&'’-]{0,40}){0,3})\b
siren¶
French company number (numéro SIREN): nine digits after SIREN, RCS or RCS and the city (RCS Paris B 552 120 222), or before RCS; the keyword is part of the match.
rre.fr.siren(text)
\b(?:(?i:siren)\s?:?\s?(?:(?i:n[°o])\.?\s?:?\s?)?|R\.?C\.?S\.?(?:\s(?:de\s)?[A-ZÉÎ][\w'’-]{0,40}(?:\s[A-ZÉÎ][\w'’-]{0,40}){0,2})?(?:\s[AB])?\s)\d{3}\s?\d{3}\s?\d{3}\b|\b\d{3}\s?\d{3}\s?\d{3}\sR\.?C\.?S\b\.?
Matches are checked with luhn; one that fails it is dropped.
siret¶
French establishment number (numéro SIRET): the SIREN and five digits, after the keyword SIRET, which is part of the match, or on its own when written 552 120 222 00013.
rre.fr.siret(text)
\b(?:(?i:siret)\s?:?\s?(?:(?i:n[°o])\.?\s?:?\s?)?\d{3}\s?\d{3}\s?\d{3}\s?\d{5}|\d{3} ?\d{3} ?\d{3} \d{5})\b
Matches are checked with fr_siret; one that fails it is dropped.
vat_number¶
French VAT number (numéro de TVA intracommunautaire): FR, a two-character key and the nine-digit SIREN, like FR 27 552 120 222 or FRK7399859412.
rre.fr.vat_number(text)
\bFR\s?[0-9A-HJ-NP-Z]{2}\s?\d{3}\s?\d{3}\s?\d{3}\b
Matches are checked with fr_vat_number; one that fails it is dropped.
Banking and payments¶
| function | checksum validator |
|---|---|
rre.fr.bic |
|
rre.fr.iban |
iban |
rre.fr.rib |
fr_rib |
bic¶
BIC (SWIFT code) of a French bank: four letters, FR and two letters or digits, with an optional three-character branch code, like BNPAFRPP or SOGEFRPPXXX.
rre.fr.bic(text)
\b[A-Z]{4}FR[A-Z0-9]{2}(?:[A-Z0-9]{3})?\b
iban¶
French IBAN: FR, two check digits and 23 letters or digits, in groups of four or in one block, like FR76 3000 6000 0112 3456 7890 189.
rre.fr.iban(text)
\bFR\d{2}(?: ?[A-Z0-9]{4}){5} ?[A-Z0-9]{3}\b
Matches are checked with iban; one that fails it is dropped.
rib¶
French bank details (RIB, relevé d'identité bancaire): bank code (5 digits), branch code (5), account number (11, letters allowed) and key (2), spaced or in one block.
rre.fr.rib(text)
\b\d{5}\s?\d{5}\s?[A-Z0-9]{11}\s?\d{2}\b
Matches are checked with fr_rib; one that fails it is dropped.
Phones and SIM cards¶
| function | checksum validator |
|---|---|
rre.fr.iccid |
luhn |
rre.fr.imsi |
|
rre.fr.mobile_number |
phone |
rre.fr.msisdn |
phone |
rre.fr.phone_number |
phone |
iccid¶
SIM card number (ICCID) of a French SIM: 8933 followed by 14 to 16 digits, without spaces, like 8933011234567890120.
rre.fr.iccid(text)
\b8933\d{14,16}\b
Matches are checked with luhn; one that fails it is dropped.
imsi¶
IMSI (subscriber identity on a SIM) of a French network: mobile country code 208, or 340, 647 or 742 overseas, and 12 more digits, 15 in all, like 208011234567890.
rre.fr.imsi(text)
\b(?:208|340|647|742)\d{12}\b
mobile_number¶
French mobile number (portable): 06 or 07 in pairs like 06 12 34 56 78, or with +33, 0033 or +33 (0), overseas departments included (0694 20 12 34); only valid French mobile numbers, not part of a longer chain like a date and time.
rre.fr.mobile_number(text)
(?<!\d[-.])(?:(?:\+|\b00)(?:33|59[046]|262)\s?(?:\(0\)\s?)?(?:6|7(?=[\s.-]?[3-9]))(?:[\s.-]?\d){8}\b|\b0(?:6|7(?=[\s.-]?[3-9]))([\s.-]?)\d{2}(?:\1\d{2}){3}\b|\b0(?:69[0-7]|639)([\s.-])\d{2}(?:\2\d{2}){2}\b)(?![-.]\d)
Matches are checked with phone (regions FR GP MQ GF RE YT BL MF, kind mobile); one that fails it is dropped.
msisdn¶
French mobile number in MSISDN form, as in telecom records: 33 and the number without its 0 or a + in front, like 33612345678, or 590, 594, 596 or 262 overseas; only valid French mobile numbers.
rre.fr.msisdn(text)
(?<!\+)\b(?:33(?:6\d|7[3-9])|(?:59[046]|262)6\d)\d{7}\b
Matches are checked with phone (regions FR GP MQ GF RE YT BL MF, kind msisdn); one that fails it is dropped.
phone_number¶
French phone number (numéro de téléphone): 0 and nine digits in pairs with one kind of separator, like 01 99 00 12 34, or with +33, 0033 or +33 (0), overseas included; only valid numbers, not part of a longer chain like a date and time.
rre.fr.phone_number(text)
(?<!\d[-.])(?:(?:\+|\b00)(?:33|59[046]|262)\s?(?:\(0\)\s?)?[1-9](?:[\s.-]?\d){8}\b|\b0[1-9]([\s.-]?)\d{2}(?:\1\d{2}){3}\b|\b0(?:59[046]|69[0-7]|26[239]|639)([\s.-])\d{2}(?:\2\d{2}){2}\b)(?![-.]\d)
Matches are checked with phone (regions FR GP MQ GF RE YT BL MF); one that fails it is dropped.
Places and addresses¶
| function | checksum validator |
|---|---|
rre.fr.postal_code_city |
|
rre.fr.street_address |
postal_code_city¶
French postal code (code postal) and town on the same line: five digits, departments 01 to 95 and overseas (97, 98), and up to six words of the place name, like 75008 Paris or 59650 Villeneuve d'Ascq; not right after another number (a RIB, a product key) or before EUR, USD, GBP, CHF or XPF (an amount).
rre.fr.postal_code_city(text)
(?<!\d[- ])\b(?:0[1-9]|[1-8]\d|9[0-578])\d{3} (?!(?:EUR|USD|GBP|CHF|XPF)\b|Euro)[A-ZÉÎ][\w'’-]{0,40}(?: (?:(?:de|du|des|la|le|les|en|sur|sous|aux?|lès) |[dl]['’]){0,2}[A-ZÉÎ][\w'’-]{0,40}){0,5}
street_address¶
French street address, number first: house number with bis or ter, then rue, avenue, boulevard, place, impasse, allée, chemin, route, quai or the like, and the name on the same line, like 12 bis rue de la Paix.
rre.fr.street_address(text)
\b\d{1,4}(?:\s?(?:(?i:bis|ter|quater)|[A-D])\b)?,?\s(?i:rue|avenue|av\.|boulevard|bd|place|impasse|allée|chemin|route|quai|cours|square|passage|faubourg|résidence|cité)\s(?:(?:de|du|des|la|le|les|aux?|à|sur|sous|en)\s|[dl]['’]){0,3}(?:\d{1,2}(?:er|ER)?\s)?[A-ZÉÎ][\w'’-]{0,40}(?: (?:(?:de|du|des|la|le|les|aux?|sur|sous|en) |[dl]['’]){0,3}(?:\d{1,2}(?:er|ER)? )?[A-ZÉÎ][\w'’-]{0,40}){0,4}
Vehicles, ships and parcels¶
| function | checksum validator |
|---|---|
rre.fr.aircraft_registration |
|
rre.fr.license_plate |
aircraft_registration¶
French aircraft registration (immatriculation): F- followed by four letters, like F-GKXA or F-ABCD.
rre.fr.aircraft_registration(text)
\bF-[A-Z]{4}\b
license_plate¶
French license plate (plaque d'immatriculation): the SIV format AB-123-CD without I, O or U or the number 000, with or without dashes, and older FNI plates ending in the department, like 123 ABC 75; not next to a dash or # (product keys, colours).
rre.fr.license_plate(text)
(?<![-#])\b(?:[A-HJ-NP-TV-Z]{2}[- ]?(?!000)\d{3}[- ]?[A-HJ-NP-TV-Z]{2}|[1-9]\d{0,3}[- ]?(?!JAN|FE[BV]|MAR|A[PV]R|MAY|JU[NL]|AUG|SEP|DEC|EUR)[A-HJ-NP-Z]{2,3}[- ]?(?:0[1-9]|[1-8]\d|9[0-5]|2[AB]|97[1-6]))\b(?!-)
Justice and police¶
| function | checksum validator |
|---|---|
rre.fr.ecli |
ecli¶
European Case Law Identifier (ECLI) of a French court decision: ECLI:FR:, the court, the year and the number, like ECLI:FR:CCASS:2020:C100123.
rre.fr.ecli(text)
\bECLI:FR:[A-Z]+:\d{4}:[A-Z0-9.]*[A-Z0-9]