# default regex which is used in case if given identifier's regex is not specified in
# 'List of national identifiers' spreadsheet
DEFAULT_REGEX = "[^+,]{1,50}$"

# List of national identifiers registers issued by European Central Bank, used to manually verify identifiers
ECB_NATIONAL_IDENTIFIERS_REGISTERS = {
    "AE_BL_CD": "https://ner.economy.ae/Search_By_BL_No.aspx",
    "AR_CUIT_CD": "https://www.cuitonline.com/",
    "AT_FB_CD": ("https://www.firmenabc.at/", "https://justizonline.gv.at/jop/web/firmenbuchabfrage"),
    "AT_GEM_CD": "http://www.statistik.at/web_de/klassifikationen/regionale_gliederungen/gemeinden/index.html",
    "AT_IDENT_CD": "https://www.usp.gv.at/Portal.Node/usp/public/content/laufender_betrieb/firmenbuch/firmenbuchabfrage"
    "/Seite.760006.html",
    "AT_LAE_CD": "http://www.iso.org/iso/home/store/catalogue_ics/catalogue_detail_ics.htm?csnumber=63546",
    "AT_ZVR_CD": "http://zvr.bmi.gv.at/Start",
    "AU_ABN_CD": ("https://www.abr.gov.au/", "https://abr.business.gov.au/Search/Advanced"),
    "AU_ACN_CD": (
        "https://asic.gov.au/online-services/search-asic-s-registers/",
        "https://connectonline.asic.gov.au/RegistrySearch/faces/landing/SearchRegisters.jspx?_adf.ctrl-state=10yzwonlb0_26",
    ),
    "BA_JIB_CD": "https://bizreg.pravosudje.ba/pls/apex/f?p=186:20:1390340018544685::NO",
    "BA_MBS_CD": "https://search.bisnode.ba/",
    "BA_PIB_CD": "https://bizreg.pravosudje.ba/pls/apex/f?p=186:20:1390340018544685::NO",
    "BE_OND_CD": "http://kbopub.economie.fgov.be/kbopub/zoeknummerform.html?lang=en",
    "BG_BULSTAT_CD": "http://reports.bulstat.bg:8081/bulstat-ireports/report.jsf?x_rpt=rpt1",
    "BG_UIC_CD": "https://public.brra.bg/CheckUps/Verifications/VerificationPersonOrg.ra",
    "BG_VAT_CD": "http://nra.bg/vatbulletin/",
    "BM_RN_CD": "https://www.registrarofcompanies.gov.bm/",
    "BR_CNPJ_CD": (
        "http://www.receita.fazenda.gov.br/PessoaJuridica/CNPJ/cnpjreva/Cnpjreva_Solicitacao.asp",
        "https://www.infoplex.com.br/",
    ),
    "BS_NBR_CD": "https://www.bahamas.gov.bs/wps/portal/public/Services/!ut/p/b1/vZPbcqowFIafxQewrHAyuYySIso5IOiNg-ABEA"
    "-VKvL0m3Z60e6ZbW92m1xl5s_61_r-RFgIsbA4JNd8m9T58ZDs384LdSmBblEqY0tXQAUjdE3qDsaig5ROMH8gkOHRfWwjIRJikJe"
    "8gBdnei-P92zkzrT4RuK1meGBO4WDPUUM3WnA_bg6ec8Lwz-fR2tJXpST1NyXz9VQTaN9FFanJnnRX7dawU9GwIjNueQEFtawYrTh"
    "0ita36i1EVjlpYF2jqxgPLPZFi4Zl6xQbiDgULcU6hK53LRam8RWfdndhtV43c63vd7HrPCPReE7VhNhka-qp1taPcGThBERCYCqq"
    "CoiMu5ILB4WmIrfCN5gvwsedDjvBINPFYIZgIGA-hx58JZH8JHH_WS0Zet30Mx3aGx7hzaUrKKDFpZwsTmyGG6giFCtUalmjcNX1s"
    "0mGzeb-eGQDuN8ojp_GzpiQDrDEVKnoQIc5J821BUHd4wGgUsVEXQH_bah9KtIddeBH5_wy6ORvf-f4ZePgomKlAGWCVZBlvFAmBV"
    "zlWgX46YZ_maXhkUdpeKOemZOdR220f48Y7kS9k9J-rJiTbizAjPLxM0kI0XezvNS84feNImaa0SAsFGbiYzxonQ8w-KTZMk87ajL"
    "XJubATXrcnTAS7Xf7_u0ro5O7OzP63FkhNKs_7pp77uNXdpZOlrqZCjHirU7OFmpG5GSHPtrMUPh_qCw1WvZTJt6zfzLFS_9IN3UO"
    "pFoVJc9wR4fq7VwqsKrqUzYxv685d4f8up0mg!!/dl4/d5/L2dBISEvZ0FBIS9nQSEh/?1dmy&urile=wcm%3apath%3a/mof_con"
    "tent/internet/all+services/c/company+search",
    "BY_NBR_CD": "https://egr.gov.by/egrn/index.jsp?content=Find",
    "BZ_TIN_CD": "https://irisbelize.bts.gov.bz/",
    "CA_BN_CD": (
        "http://www.cra-arc.gc.ca/bn/",
        "https://beta.canadasbusinessregistries.ca/search",
    ),
    "CA_REG_ID_CD": (
        "https://beta.canadasbusinessregistries.ca/search",
        "https://www.ic.gc.ca/app/scr/cc/CorporationsCanada/fdrlCrpSrch.html",
    ),
    "CH_ID_CD": "https://www.zefix.ch/en/search/entity/welcome",
    "CH_UID_CD": (
        "https://www.uid.admin.ch",
        "https://www.zefix.ch/en/search/entity/welcome",
    ),
    "CL_RUT_CD": "https://zeus.sii.cl/cvc_cgi/nar/nar_ingrut",
    "CN_CC_CD": "http://bj.gsxt.gov.cn/",
    "CO_NIT_CD": "https://www.rues.org.co/RM",
    "CY_CBCID_CD": "https://www.centralbank.cy/images/media/xls/CY_CBCID_CD.xlsx",
    "CY_DRCOR_CD": "https://efiling.drcor.mcit.gov.cy/DrcorPublic/SearchForm.aspx?sc=0&cultureInfo=en-AU",
    "CY_GG_CD": "https://www.centralbank.cy/images/media/xls/CY_GG_CD.xlsx",
    "CY_IF_CD": "https://www.centralbank.cy/en/statistics/money-and-banking-statistics-and-financial-accounts/lists-of-"
    "financial-institutions",
    "CZ_ICO_CD": (
        "https://or.justice.cz/ias/ui/rejstrik",
        "https://apl.czso.cz/irsw/",
    ),
    "CZ_NID_CD": "https://apl.cnb.cz/apljerrsdad/JERRS.WEB15.BASIC_LISTINGS?p_lang=cz",
    "DE_GNR_CD": "https://www.handelsregister.de/rp_web/welcome.do",
    "DE_HRA_CD": "https://www.handelsregister.de/rp_web/welcome.do",
    "DE_HRB_CD": "https://www.handelsregister.de/rp_web/welcome.do",
    "DE_PR_CD": "https://www.handelsregister.de/rp_web/welcome.do",
    "DE_TRD_RGSTR_CD": "https://www.handelsregister.de/rp_web/welcome.do",
    "DE_VR_CD": "https://www.handelsregister.de/rp_web/welcome.do",
    "DK_CVR_CD": "http://www.cvr.dk",
    "DK_FT_CD": "http://vut.finanstilsynet.dk/en/Tal-og-fakta/Virksomheder-under-tilsyn/VUT-database.aspx",
    "EC_RUC_CD": "https://www.compraspublicas.gob.ec/ProcesoContratacion/compras/EP/BusquedaProveedorCpc.cpe",
    "EE_RG_CD": "https://ariregister.rik.ee/",
    "ES_NIF_CD": "http://www.infocif.es/",
    "FI_ALV_CD": "http://fi.vat-search.eu/",
    "FI_SIRA_CD": "http://www.suomenpankki.fi/en/tilastot/sijoitusrahastot/Pages/sijoitusrahastolista.aspx",
    "FI_Y_CD": "https://tietopalvelu.ytj.fi/yrityshaku.aspx?kielikoodi=3",
    "FR_CIB": "https://www.regafi.fr/spip.php?rubrique3",
    "FR_IF_CD": "https://www.ecb.europa.eu/stats/financial_corporations/list_of_financial_institutions/html/index.en.html",
    "FR_RNA_CD": "https://www.data.gouv.fr/fr/datasets/repertoire-national-des-associations-rna/",
    "FR_SIREN_CD": "https://www.sirene.fr/sirene/public/accueil",
    "GB_CRN_CD": "https://beta.companieshouse.gov.uk",
    "GB_UTR_CD": "https://www.gov.uk/government/organisations/hm-revenue-customs",
    "GG_RN_CD": "https://www.greg.gg/webCompSearch.aspx",
    "GR_AFM_CD": "https://www.businessregistry.gr/publicity/index",
    "GR_IMO_CD": "http://www.imonumbers.lrfairplay.com/",
    "HK_CR_CD": (
        "https://www.icris.cr.gov.hk/csci/login_i.do?loginType=iguest&OPT_01=1&OPT_02=1&OPT_03=1&OPT_04=1&OPT_05=1&OPT_"
        "06=1&OPT_07=1&OPT_08=1&OPT_09=1",
        "http://www.hongkongcompanylist.com/",
    ),
    "HR_MBS_CD": "https://sudreg.pravosudje.hr/registar/",
    "HR_MB_CD": "http://www.dzs.hr/",
    "HR_OIB_CD": "http://oib.oib.hr/SaznajOibWeb/pravnaOsoba.html",
    "HU_CEG_CD": "https://www.e-cegjegyzek.hu/?cegkereses",
    "HU_KOZ_CD": "https://www.e-cegjegyzek.hu/?cegkereses",
    "IE_CRO_CD": "https://search.cro.ie",
    "IE_GOV_CD": "https://www.centralbank.ie/statistics/statistical-reporting-requirements/anacredit-in-ireland",
    "IL_TAX_CD": ("https://ica.justice.gov.il/IcaSite/", "https://www.vatify.eu/israel-vat-number.html"),
    "IM_RN_CD": "https://services.gov.im/companies-registry",
    "IM_TAX_CD": "https://www.gov.im/categories/tax-vat-and-your-money/income-tax-and-national-insurance/personal-tax/"
    "reference-numbers/",
    "IN_CIN_CD": "http://www.mca.gov.in/mcafoportal/checkCompanyName.do",
    "IT_UCITS_CD": "https://infostat.bancaditalia.it/giava-inquiry-public/flex/Giava/GIAVAFEInquiry.html#",
    "JP_CN_CD": (
        "http://www.nta.go.jp/foreign_language/corporate_number/",
        "https://www2.tse.or.jp/tseHpFront/JJK020010Action.do?Show=Show",
    ),
    "KR_TIN_CD": "http://company.nett.kr/",
    "LI_FL_CD": "https://www.oera.li/cr-portal/suche/suche.xhtml",
    "LT_JAR_CD": "http://www.registrucentras.lt/jar/index_en.php",
    "LU_IF_CD": "https://supervisedentities.apps.cssf.lu/index.html?language=fr&type=OPC#Home",
    "LU_RCS_CD": "https://lu.kompass.com",
    "LU_VAT_CD": "https://lu.kompass.com",
    "LV_FON_CD": "https://www.bank.lv/en/statistics/information-for-data-users/lists/investment-funds-of-the-republic-"
    "of-latvia",
    "LV_NBR_CD": "http://www.lursoft.lv/en/data-bases-of-companies",
    "LV_VAT_CD": "http://www.lursoft.lv/en/data-bases-of-companies",
    "MC_CIB": "https://www.regafi.fr/spip.php?rubrique3",
    "MC_NIS_CD": "http://www.imsee.mc/Demarches-et-Services/Repertoire-du-NIS",
    "MC_RCI_CD": "http://www.rci.gouv.mc/rc/",
    "MT_CNUM_CD": "https://registry.mbr.mt/ROC/index.jsp#companySearch.do?action=companyDetails",
    "MX_RFC_CD": ("https://www.gob.mx/busqueda", "https://www.dateas.com/es/explore/empresas-mexicanas/"),
    "MY_CRN_CD": ("https://www.ssm.com.my/Pages/Quick_Link_backup/e-Search.aspx", "https://www.mysbusiness.com/"),
    "NC_NBR_CD": "https://www.isee.nc/ridet#liste-d-entreprises",
    "NL_KVK_CD": "http://www.kvk.nl",
    "NL_RSIN_CD": "http://www.kvk.nl",
    "NO_NBR_CD": "https://w2.brreg.no/enhet/sok/",
    "PA_RUC_CD": "http://www.panamacompra.gob.pa/ambientepublico/AP_BuscarProveedorBA.aspx?Popup=True&Texto=",
    "PE_RUC_CD": "https://dgi.mef.gob.pa/Registro.php#:~:text=El%20Registro%20%C3%9Anico%20de%20Contribuyente,personas%"
    "20naturales%2C%20comunidades%2C%20sociedades%2C",
    "PL_KRS_CD": "https://ems.ms.gov.pl/krs/wyszukiwaniepodmiotu?t:lb=t",
    "PL_NIP_CD": ("https://ems.ms.gov.pl/krs/wyszukiwaniepodmiotu?t:lb=t", "https://www.owg.pl/obf/wynik?pageSize=10"),
    "PL_REGON_CD": "https://ems.ms.gov.pl/krs/wyszukiwaniepodmiotu?t:lb=t",
    "PL_VAT_CD": "https://ems.ms.gov.pl/krs/wyszukiwaniepodmiotu?t:lb=t",
    "PT_ASF_CD": "https://www.asf.com.pt",
    "PT_FSA_CD": "http://www.bportugal.pt",
    "PT_IF_CD": "https://www.cmvm.pt",
    "RO_TRN_CD": "https://www.listafirme.ro",
    "RS_MB_CD": ("https://pretraga2.apr.gov.rs/unifiedentitysearch", "https://www.vatify.eu/serbia-vat-number.html"),
    "RS_PIB_CD": ("https://pretraga2.apr.gov.rs/unifiedentitysearch", "http://www.companywall.rs/"),
    "RU_INN_CD": ("https://service.nalog.ru/inn.do", "https://www.k-agent.ru/en"),
    "SE_FIN_CD": "http://www.fi.se/Folder-EN/Startpage/Register/Company-register/",
    "SE_ORG_CD": "http://www.bolagsverket.se/en/info/buy/e-services/company-information",
    "SG_ROB_CD": (
        "https://www.tis.bizfile.gov.sg/ngbtisinternet/faces/oracle/webcenter/portalapp/pages/TransactionMain.jspx?sele"
        "ctedETransId=dirSearch",
        "https://www.rikvin.com/tools/singapore-company-name-check/",
    ),
    "SI_DAV_CD": "http://www.ajpes.si/prs/default.asp",
    "SI_DDV_CD": "http://www.ajpes.si/prs/default.asp",
    "SI_MAT_CD": "http://www.ajpes.si/prs/default.asp",
    "SK_ICO_CD": "https://rpo.statistics.sk/rpo",
    "SK_IF_CD": "https://www.nbs.sk/en/statistics/financial-institutions/money-market-funds-and-investment-funds/list-"
    "of-investment-funds",
    "SM_COE_CD": "https://registroimprese.cc.sm/",
    "TH_NBR_CD": (
        "https://thailandenterprise.com/enterprise/thai-pat-fin-co-ltd.383331383337.html",
        "https://www.dataforthai.com/company/0205555006690/",
    ),
    "TR_VKN_CD": "https://www.nvi.gov.tr/",
    "TW_TAX_CD": "https://gcis.nat.gov.tw/mainNew/English/subclassEnAction.do?method=getFile&pk=103",
    "US_EIN_CD": (
        "https://www.irs.gov/businesses/small-businesses-self-employed/employer-id-numbers-eins",
        "https://eintaxid.com/",
    ),
    "UY_RUT_CD": "https://servicios.dgi.gub.uy/ServiciosEnLinea/dgi--servicios-en-linea--consulta-de-certifcado-unico",
}

# List of national identifiers issued by European Central Bank
ECB_NATIONAL_IDENTIFIERS = {
    "AE_BL_CD": "^[0-9]{4,5}$",
    "AR_CUIT_CD": "^[0-9]{2}-[0-9]{8}-[0-9]{1}$",
    "AT_FB_CD": "^[0-9]{1,6}[A-Za-z][0-9]{0,3}$",
    "AT_GEM_CD": "^[0-9]{5}$",
    "AT_IDENT_CD": "^[0-9]{1,8}$",
    "AT_LAE_CD": "^[0-9]$",
    "AT_ZVR_CD": "^[0-9]{1,10}$",
    "AU_ABN_CD": "^[0-9]{2} [0-9]{3} [0-9]{3} [0-9]{3}$",
    "AU_ACN_CD": "^[0-9]{3} [0-9]{3} [0-9]{3}$",
    "BA_JIB_CD": "^[0-9]{13}$",
    "BA_MBS_CD": "^[0-9]{1,2}-[0-9]{3,5}|[0-9]{1}-[0-9]{4}-[0-9]{2}|[0-9]{2}-[0-9]{2}-[0-9]{4}-[0-9]{2}$",
    "BA_PIB_CD": "^[0-9]{12}$",
    "BE_OND_CD": "^[0-1][0-9]{9}$",
    "BG_BULSTAT_CD": "(^[0-9]{9}$)|(^[0-9]{10}$)|(^[0-9]{13}$)",
    "BG_UIC_CD": "(^[0-9]{9}$)|(^[0-9]{13}$)$",
    "BG_VAT_CD": "^BG([0-9]{9,10})$",
    "BIC": "(^[A-Z0-9]{8}$)|(^[A-Z0-9]{11}$)$",
    "BM_RN_CD": "^[0-9]{4,5}$",
    "BR_CNPJ_CD": "^[0-9]{2}[.][0-9]{3}[.][0-9]{3}/[0-9]{4}-[0-9]{2}$",
    "BS_NBR_CD": "^[0-9]{5,7}$",
    "BY_NBR_CD": "^[0-9]{9}$",
    "BZ_TIN_CD": "^[0-9]{6}$",
    "CA_BN_CD": "^[0-9]{9}$",
    "CA_REG_ID_CD": "^BC[0-9]{7}|[0-9]{7}$",
    "CH_ID_CD": "^CH-[0-9]{3}-[0-9]{7}-[0-9]{1}$",
    "CH_NUMMER": "^CH-[0-9]{3}[.][0-9][.][0-9]{3}[.][0-9]{3}-[0-9]$",
    "CH_UID_CD": "^CHE-[0-9]{3}[.][0-9]{3}[.][0-9]{3}$",
    "CL_RUT_CD": "^[0-9]{2}.[0-9]{3}.[0-9]{3}-[K0-9]|[0-9]{8}-[K0-9]$",
    "CN_CC_CD": "^[A-Z0-9]{18}$",
    "CO_NIT_CD": "^[0-9]{9}-[0-9]$",
    "CY_CBCID_CD": "^[A-Z]{2}[0-9]{1,8}$",
    "CY_DRCOR_CD": "^[COP][0-9]{1,8}$",
    "CY_GG_CD": "^S13[0-9]{8}$",
    "CY_IF_CD": "^CYIF[0-9]{4}$",
    "CY_OTHER_CD": DEFAULT_REGEX,
    "CY_PF_CD": "^PF[0-9]{1,4}$",
    "CY_TIC_CD": "^[0-9]{8}[A-Z]$",
    "CY_VAT_CD": "^[013459][0-9]{7}[A-Z]$",
    "CZ_ICO_CD": "^[0-9]{8}$",
    "CZ_NID_CD": "(^[0-9]{8}$)|(^[0-9]{10}$)",
    "DE_GNR_CD": "^G[nN]R[0-9]{1,6}[A-Z]{0,5}-[A-Z][0-9]{4}$",
    "DE_HRA_CD": "^HRA[0-9]{1,6}[A-Z]{0,5}-[A-Z][0-9]{4}$",
    "DE_HRB_CD": "^HRB[0-9]{1,6}[A-Z]{0,5}-[A-Z][0-9]{4}$",
    "DE_PR_CD": "^PR[0-9]{1,6}[A-Z]{0,5}-[A-Z][0-9]{4}$",
    "DE_TAX_CD": "^[0-9]{13}$",
    "DE_TRD_RGSTR_CD": "^((G(n|N)R)|(HRA)|(HRB)|(PR)|(VR))[0-9]{1,6}[A-Z]{0,5}-[A-Z][0-9]{4}$",
    "DE_VAT_CD": "^DE[0-9]{9}$",
    "DE_VR_CD": "^VR[0-9]{1,6}[A-Z]{0,5}-[A-Z][0-9]{4}$",
    "DK_CVR_CD": "^[0-9]{8}$",
    "DK_FT_CD": "(^[0-9]+$)|(^[0-9]+-[0-9]+$)",
    "DK_SE_CD": "^[0-9]{8}$",
    "EC_RUC_CD": "^[0-9]{13}$",
    "EE_FON_CD": "^[0-9]{1,4}$",
    "EE_RG_CD": "^[0-9]{8}$",
    "ES_NIF_CD": "^[A-Z0-9]{9}$",
    "FI_ALV_CD": "^FI[0-9]{8}$",
    "FI_SIRA_CD": "^[0-9]{8}#[0-9]{3}$",
    "FI_Y_CD": "^[0-9]{7}-?[0-9]$",
    "FR_CIB": "^[0-9]{5}$",
    "FR_IF_CD": "^FR[A-Z0-9]{10}$",
    "FR_RNA_CD": "^[A-Z][0-9]{9}$",
    "FR_SIREN_CD": "^[0-9]{9}$",
    "GB_CRN_CD": "^[A-Z0-9]{8}$",
    "GB_FSR_CD": "^[0-9]{6}$",
    "GB_UTR_CD": "(^[0-9]{10}$)|(^[0-9]{9}K$)",
    "GB_VAT_CD": "^(GB([0-9]{9}|[0-9]{12})|GB(GD|HA)[0-9]{3})$",
    "GG_RN_CD": "^[0-9]{5}$",
    "GR_AFM_CD": "^[0-9]{9}$",
    "GR_IMO_CD": "^[0-9]{7}$",
    "HK_BR_CD": "^[0-9]{8}-[0-9]{3}.[0-9]{2}.[0-9]{2}-[A-Z]$",
    "HK_CR_CD": "^([A-Z]{1}[0-9]{7}|[0-9]{7})$",
    "HR_MBS_CD": "^[01][0-9]{8}$",
    "HR_MB_CD": "^[0-9]{8}$",
    "HR_OIB_CD": "^[0-9]{11}$",
    "HU_CEG_CD": "^[0-9]{2}-[0-9]{2}-[0-9]{6}$",
    "HU_FB_CD": "^FB([0-9]{6}|[0-9]{3}[A-Z][0-9]{2})$",
    "HU_KOZ_CD": "^HU[0-9]{8}$",
    "HU_TOR_CD": "^[0-9]{8}$",
    "ID_NPWP_CD": "^[0-9]{2}.[0-9]{3}.[0-9]{3}.[0-9]{1}-[0-9]{3}.[0-9]{3}$",
    "IE_CRO_CD": "^[1-9][0-9]{0,6}$",
    "IE_GOV_CD": "^(GV[0-9]{4}|LA[0-9]{3})$",
    "IE_VAT_CD": "^IE[A-Z0-9]{1,9}$",
    "IL_TAX_CD": "^[0-9]{9}$",
    "IM_RN_CD": "^[0-9]{6}[A-Z]$",
    "IM_TAX_CD": "^[HCX][0-9]{6}-[0-9]{2}$",
    "IN_CIN_CD": "^[A-Z0-9]{21}$",
    "IN_PAN_CD": "^[A-Z0-9]{10}$",
    "IT_CCIAA_CD": "^[A-Z]{2}[0-9]{7}$",
    "IT_CF_CD": "^[0-9]{11}$",
    "IT_UCITS_CD": "^[0-9]{1,7}$",
    "JE_TAX_CD": "^[A-Z]{2}[0-9]{5}$",
    "JP_CN_CD": "^[0-9]{13}$",
    "KR_TIN_CD": "^[0-9]{3}-[0-9]{2}-[0-9]{5}$",
    "LI_FL_CD": "^FL-[0-9]{4}.[0-9]{3}.[0-9]{3}-[0-9]$",
    "LT_INV_CD": "(^[A-Z]{1}[0-9]{3}$)|(^SF[0-9]{3}$)|(^[A-Z]{3}-[0-9]{2}/[0-9]{2}$)|(^[A-Z]{3}-[A-Z]{4}$)",
    "LT_JAR_CD": "^[0-9]{9}$",
    "LU_IF_CD": "^[A-Z][0-9]{6}C[0-9]{5}$",
    "LU_RCS_CD": "^[A-Z][0-9]+$",
    "LU_VAT_CD": "^[0-9]{8}$",
    "LV_FON_CD": "(^LVAF[0-9]{3}[AB0-9]{1}[0-9]{2}$)|(^LVIF[0-9]{3}[ABCDEF0-9]{1}[0-9]{2}$)|(^LVB[0-9]{6}$)|"
    "(^LVVF[0-9]{6}$)|(^LV[0-9]{11}$)",
    "LV_NBR_CD": "^[0-9]{11}$",
    "LV_VAT_CD": "^LV[0-9]{11}$",
    "MC_CIB": "^[0-9]{5}$",
    "MC_NIS_CD": "^[0-9]{2,4}[A-Z][0-9]{5}$",
    "MC_RCI_CD": "^[0-9]{2}[A-Z]{1,3}[0-9]{5}$",
    "MH_NBR_CD": "^[0-9]{4,6}$",
    "MT_CNUM_CD": DEFAULT_REGEX,
    "MT_OLE_CD": DEFAULT_REGEX,
    "MT_VAT_CD": "^[0-9]{8}$",
    "MX_RFC_CD": "^[A-Z]{3}-[0-9]{6}-[A-Z0-9]{3}$",
    "MY_CRN_CD": "^[0-9]{6}-[A-Z]$",
    "NC_NBR_CD": "^[0-9]{7}$",
    "NL_KVK_CD": "^[0-9]{8}$",
    "NL_RSIN_CD": "^[0-9]{9}$",
    "NO_NBR_CD": "^[0-9]{9}$",
    "PA_RUC_CD": DEFAULT_REGEX,
    "PE_RUC_CD": "^[0-9]{11}$",
    "PL_KRS_CD": "^[0-9]+$",
    "PL_NIP_CD": "^[0-9]{10}$",
    "PL_REGON_CD": "(^[0-9]{9}$)|(^[0-9]{14}$)",
    "PL_VAT_CD": "^PL[0-9]{10}$",
    "PT_ASF_CD": "^[0-9]{1,4}$",
    "PT_FSA_CD": "^[0-9]{1,6}$",
    "PT_IF_CD": "^[0-9]{1,8}$",
    "PT_NIF_CD": "^[0-9]{9}$",
    "RO_CUI_CD": "^RO[0-9]{1,10}$",
    "RO_TAX_CD": "^RO[0-9]{1,10}$",
    "RO_TRN_CD": "^J[0-9]{2}/[0-9]{1,9}/[12][0-9]{3}$",
    "RS_MB_CD": "^[0-9]{8}$",
    "RS_PIB_CD": "^[1-9][0-9]{8}$",
    "RU_INN_CD": "^[0-9]{10}$",
    "RU_OGRN_CD": "^[0-9]{13}$",
    "SE_FIN_CD": "^[0-9]{5}$",
    "SE_MOM_CD": "^SE[0-9]{12}$",
    "SE_ORG_CD": "^[0-9]{2}[2-9][0-9]{3}-?[0-9]{4}$",
    "SG_ROB_CD": "^[0-9]{9}[A-Z]|[A-Z][0-9]{2}[A-Z]{2}[0-9]{4}[A-Z]$",
    "SI_DAV_CD": "^[0-9]{8}$",
    "SI_DDV_CD": "^SI[0-9]{8}$",
    "SI_MAT_CD": "^[0-9]{10}$",
    "SK_ICO_CD": "^[0-9]{8}$",
    "SK_IF_CD": "^SK[0-9]{8}[A-Z]{3}[0-9]{2}$",
    "SM_COE_CD": "^[0-9]{5}$",
    "TH_NBR_CD": "^[0-9]{13}$",
    "TR_VKN_CD": "^[0-9]{1,10}$",
    "TW_TAX_CD": "^[0-9]{8}$",
    "US_CIK_CD": "^[0-9]{10}$",
    "US_DSFN_CD": "^[0-9]{6,7}$",
    "US_EIN_CD": "^[0-9]{2}-[0-9]{7}$",
    "UY_RUT_CD": "^[0-9]{12}$",
    "AT_NOTAP_CD": DEFAULT_REGEX,
    "DE_NOTAP_CD": DEFAULT_REGEX,
    "DK_NOTAP_CD": DEFAULT_REGEX,
    "FI_NOTAP_CD": DEFAULT_REGEX,
    "IE_NOTAP_CD": DEFAULT_REGEX,
    "LU_NOTAP_CD": DEFAULT_REGEX,
    "SE_NOTAP_CD": DEFAULT_REGEX,
    "GEN_VAT_CD": DEFAULT_REGEX,
    "GEN_TAX_CD": DEFAULT_REGEX,
    "GEN_NBR_ENTTY_CD": DEFAULT_REGEX,
    "GEN_TRD_RGSTR_ENTTY_CD": DEFAULT_REGEX,
    "GEN_NSI_ENTTY_CD": DEFAULT_REGEX,
    "GEN_NCB_ENTTY_CD": DEFAULT_REGEX,
    "GEN_NSA_ENTTY_CD": DEFAULT_REGEX,
    "GEN_PS_CD": DEFAULT_REGEX,
    "GEN_IPF_CD": DEFAULT_REGEX,
    "GEN_OTHER_CD": DEFAULT_REGEX,
}

COUNTRY_IDENTIFIER_RANK = {
    "AE": ((1, "AE_BL_CD"),),
    "AR": ((1, "AR_CUIT_CD"),),
    "AT": (
        (1, "AT_IDENT_CD"),
        (2, "AT_FB_CD"),
        (3, "AT_ZVR_CD"),
        (4, "AT_GEM_CD"),
        (5, "AT_LAE_CD"),
        (6, "AT_NOTAP_CD"),
    ),
    "AU": (
        (1, "AU_ABN_CD"),
        (2, "AU_ACN_CD"),
    ),
    "BA": (
        (1, "BA_MBS_CD"),
        (2, "BA_JIB_CD"),
        (3, "BA_PIB_CD"),
    ),
    "BE": ((1, "BE_OND_CD"),),
    "BG": (
        (1, "BG_BULSTAT_CD"),
        (1, "BG_UIC_CD"),
        (2, "BG_VAT_CD"),
    ),
    "BM": ((1, "BM_RN_CD"),),
    "BR": ((1, "BR_CNPJ_CD"),),
    "BS": ((1, "BS_NBR_CD"),),
    "BY": ((1, "BY_NBR_CD"),),
    "BZ": ((1, "BZ_TIN_CD"),),
    "CA": (
        (1, "CA_BN_CD"),
        (2, "CA_REG_ID_CD"),
    ),
    "CH": (
        (1, "CH_UID_CD"),
        (2, "CH_ID_CD"),
        (3, "CH_NUMMER"),
    ),
    "CL": ((1, "CL_RUT_CD"),),
    "CN": ((1, "CN_CC_CD"),),
    "CO": ((1, "CO_NIT_CD"),),
    "CY": (
        (1, "CY_CBCID_CD"),
        (1, "CY_DRCOR_CD"),
        (1, "CY_GG_CD"),
        (1, "CY_PF_CD"),
        (2, "CY_IF_CD"),
        (3, "CY_VAT_CD"),
        (4, "CY_TIC_CD"),
        (6, "CY_OTHER_CD"),
    ),
    "CZ": (
        (1, "CZ_ICO_CD"),
        (2, "CZ_NID_CD"),
    ),
    "DE": (
        (1, "DE_TRD_RGSTR_CD"),
        (2, "DE_VAT_CD"),
        (3, "DE_TAX_CD"),
        (4, "DE_NOTAP_CD"),
    ),
    "DK": (
        (1, "DK_CVR_CD"),
        (2, "DK_FT_CD"),
        (3, "DK_SE_CD"),
        (4, "DK_NOTAP_CD"),
    ),
    "EC": ((1, "EC_RUC_CD"),),
    "EE": (
        (1, "EE_FON_CD"),
        (1, "EE_RG_CD"),
    ),
    "ES": ((1, "ES_NIF_CD"),),
    "FI": (
        (1, "FI_Y_CD"),
        (2, "FI_ALV_CD"),
        (3, "FI_SIRA_CD"),
        (4, "FI_NOTAP_CD"),
    ),
    "FR": (
        (1, "FR_CIB"),
        (1, "FR_IF_CD"),
        (1, "FR_RNA_CD"),
        (1, "FR_SIREN_CD"),
    ),
    "GB": (
        (1, "GB_CRN_CD"),
        (2, "GB_UTR_CD"),
        (3, "GB_FSR_CD"),
        (4, "GB_VAT_CD"),
    ),
    "GG": ((1, "GG_RN_CD"),),
    "GR": (
        (1, "GR_AFM_CD"),
        (1, "GR_IMO_CD"),
    ),
    "HK": ((1, "HK_CR_CD"),),
    "HR": (
        (1, "HR_OIB_CD"),
        (2, "HR_MB_CD"),
        (3, "HR_MBS_CD"),
    ),
    "HU": (
        (1, "HU_CEG_CD"),
        (1, "HU_FB_CD"),
        (1, "HU_KOZ_CD"),
        (1, "HU_TOR_CD"),
    ),
    "ID": ((1, "ID_NPWP_CD"),),
    "IE": (
        (1, "IE_CRO_CD"),
        (2, "IE_GOV_CD"),
        (3, "IE_VAT_CD"),
        (4, "IE_NOTAP_CD"),
    ),
    "IL": ((1, "IL_TAX_CD"),),
    "IM": (
        (1, "IM_RN_CD"),
        (2, "IM_TAX_CD"),
    ),
    "IN": (
        (1, "IN_CIN_CD"),
        (2, "IN_PAN_CD"),
    ),
    "IT": (
        (1, "IT_CF_CD"),
        (1, "IT_UCITS_CD"),
        (2, "IT_CCIAA_CD"),
    ),
    "JE": ((1, "JE_TAX_CD"),),
    "JP": ((1, "JP_CN_CD"),),
    "KR": ((1, "KR_TIN_CD"),),
    "LI": ((1, "LI_FL_CD"),),
    "LT": (
        (1, "LT_JAR_CD"),
        (2, "LT_INV_CD"),
    ),
    "LU": (
        (1, "LU_IF_CD"),
        (1, "LU_RCS_CD"),
        (1, "LU_VAT_CD"),
        (2, "LU_NOTAP_CD"),
    ),
    "LV": (
        (1, "LV_NBR_CD"),
        (2, "LV_VAT_CD"),
        (4, "LV_FON_CD"),
    ),
    "MC": (
        (1, "MC_CIB"),
        (1, "MC_RCI_CD"),
        (2, "MC_NIS_CD"),
    ),
    "MH": ((1, "MH_NBR_CD"),),
    "MT": (
        (1, "MT_CNUM_CD"),
        (2, "MT_VAT_CD"),
        (3, "MT_OLE_CD"),
    ),
    "MX": ((1, "MX_RFC_CD"),),
    "MY": ((1, "MY_CRN_CD"),),
    "NC": ((1, "NC_NBR_CD"),),
    "NL": (
        (1, "NL_KVK_CD"),
        (2, "NL_RSIN_CD"),
    ),
    "NO": ((1, "NO_NBR_CD"),),
    "PA": ((1, "PA_RUC_CD"),),
    "PE": ((1, "PE_RUC_CD"),),
    "PL": (
        (1, "PL_REGON_CD"),
        (2, "PL_KRS_CD"),
        (3, "PL_NIP_CD"),
        (4, "PL_VAT_CD"),
    ),
    "PT": (
        (1, "PT_NIF_CD"),
        (2, "PT_FSA_CD"),
        (3, "PT_IF_CD"),
        (4, "PT_ASF_CD"),
    ),
    "RO": (
        (1, "RO_CUI_CD"),
        (2, "RO_TAX_CD"),
        (3, "RO_TRN_CD"),
    ),
    "RS": (
        (1, "RS_PIB_CD"),
        (2, "RS_MB_CD"),
    ),
    "RU": (
        (1, "RU_INN_CD"),
        (2, "RU_OGRN_CD"),
    ),
    "SE": (
        (1, "SE_ORG_CD"),
        (2, "SE_FIN_CD"),
        (3, "SE_MOM_CD"),
        (4, "SE_NOTAP_CD"),
    ),
    "SG": ((1, "SG_ROB_CD"),),
    "SI": (
        (1, "SI_MAT_CD"),
        (2, "SI_DAV_CD"),
        (3, "SI_DDV_CD"),
    ),
    "SK": (
        (1, "SK_ICO_CD"),
        (1, "SK_IF_CD"),
    ),
    "SM": ((1, "SM_COE_CD"),),
    "TH": ((1, "TH_NBR_CD"),),
    "TR": ((1, "TR_VKN_CD"),),
    "TW": ((1, "TW_TAX_CD"),),
    "US": (
        (1, "US_EIN_CD"),
        (2, "US_CIK_CD"),
        (3, "US_DSFN_CD"),
    ),
    "UY": ((1, "UY_RUT_CD"),),
    "GEN": (
        (21, "GEN_VAT_CD"),
        (22, "GEN_TAX_CD"),
        (23, "GEN_NBR_ENTTY_CD"),
        (24, "GEN_TRD_RGSTR_ENTTY_CD"),
        (25, "GEN_NSI_ENTTY_CD"),
        (26, "GEN_NCB_ENTTY_CD"),
        (27, "GEN_NSA_ENTTY_CD"),
        (28, "GEN_PS_CD"),
        (29, "GEN_IPF_CD"),
        (30, "GEN_OTHER_CD"),
    ),
}

# List of other identifiers issued by Narodná banka Slovenska
NBS_IDENTIFIERS = {
    "ICO_NI": "^[0-9]{8}[a-z]{1}$",  # IČO NI is issued by NBS for subjects with duplicate national identifier (IČO).
    "NIC": "^[0-9]{8}N[0-9]{6}$",  # NIČ is issued by NBS for foreign (non SK) subjects.
}

# List of both NBS and ECB identifiers
IDENTIFIER_FORMATS = {**ECB_NATIONAL_IDENTIFIERS, **NBS_IDENTIFIERS}

# GEN Identifiers can be used by countries outside EU.
# List of exceptions when checking identifier country, used in formats.verify_national_identifier_country
GEN_IDENTIFIER_COUNTRY_EXCEPTIONS = (
    "AE",
    "AR",
    "AU",
    "BA",
    "BM",
    "BR",
    "BS",
    "BY",
    "BZ",
    "CA",
    "CH",
    "CL",
    "CN",
    "CO",
    "EC",
    "GB",
    "GG",
    "HK",
    "ID",
    "IL",
    "IM",
    "IN",
    "JE",
    "JP",
    "KR",
    "LI",
    "MH",
    "MX",
    "MY",
    "NC",
    "NO",
    "PA",
    "PE",
    "RS",
    "RU",
    "SG",
    "SM",
    "TH",
    "TR",
    "TW",
    "US",
    "UY",
)

DE_TRD_RGSTR_CD_XJUSTIZ_ID = (
    "R3101",
    "Y1201",
    "D3101",
    "D3201",
    "Y1101",
    "R1901",
    "Y1102",
    "Y1303",
    "D4102",
    "D2102",
    "P3101",
    "M1305",
    "M1202",
    "T2101",
    "R2108",
    "Y1301",
    "D4201",
    "D4301",
    "F1103",
    "R2101",
    "R2201",
    "R3201",
    "P1103",
    "H1101",
    "U1206",
    "D4401",
    "R2707",
    "G1103",
    "M1103",
    "D2201",
    "R2402",
    "U1104",
    "R1202",
    "R3103",
    "R1101",
    "Y1105",
    "Y1106",
    "M1602",
    "R2503",
    "X1112",
    "M1201",
    "G1207",
    "B8536",
    "M1405",
    "M1603",
    "M1301",
    "D3304",
    "R2507",
    "Y1203",
    "M1406",
    "Y1108",
    "P2204",
    "N1202",
    "Y1205",
    "N1303",
    "R2103",
    "R2602",
    "K1101",
    "R2404",
    "M1502",
    "P2305",
    "Y1109",
    "Y1302",
    "P2408",
    "D4501",
    "V1102",
    "D5701",
    "R2604",
    "Y1206",
    "T3201",
    "M1607",
    "D2304",
    "X1517",
    "R1304",
    "T2210",
    "R3306",
    "M1203",
    "M1608",
    "R1402",
    "T3304",
    "D2404",
    "V1103",
    "U1308",
    "R2307",
    "M1706",
    "X1721",
    "T3104",
    "N1305",
    "P2507",
    "T2304",
    "B8535",
    "M1809",
    "Y1304",
    "D2505",
    "V1104",
    "R1504",
    "T2214",
    "Y1110",
    "D2601",
    "R2713",
    "N1105",
    "V1105",
    "G1309",
    "R1102",
    "Y1111",
    "D3310",
    "M1114",
    "P3210",
    "P3313",
    "V1107",
    "R2809",
    "N1107",
    "D2803",
    "X1321",
    "Y1209",
    "Y1208",
    "G1312",
    "R2204",
    "D3410",
    "N1205",
    "N1206",
    "Y1210",
    "Y1211",
    "V1109",
    "V1110",
    "D4608",
    "N1308",
    "R3208",
    "R2909",
    "Y1112",
    "Y1113",
    "Y1307",
    "V1111",
    "V1112",
    "P2106",
    "Y1214",
    "R2706",
    "W1215",
    "N1209",
    "D3413",
    "B8534",
    "Y1308",
    "P2613",
    "D2910",
    "B8537",
    "V1115",
    "P2716",
    "N1112",
    "D3508",
    "Y1114",
    "M1710",
    "M1906",
    "N1210",
    "T2408",
    "R1608",
    "D4708",
    "T3403",
)
