Skip to content

Instantly share code, notes, and snippets.

@gabrielengel
Created September 21, 2020 18:14
Show Gist options
  • Save gabrielengel/b77ddd08666b18d7a06e008a75ce0109 to your computer and use it in GitHub Desktop.
Save gabrielengel/b77ddd08666b18d7a06e008a75ce0109 to your computer and use it in GitHub Desktop.
Regular Expressions for passports
passports = {
_generic: /^(\b([A-Za-z]\s*){1,2}\s*(\d\s*){7})/,
austria: /^[A-z] ?[0-9]{7}$/,
belgium: /^[A-z]{2}[0-9]{6}$/,
bulgaria: /^[0-9]{9}$/,
croatia: /^[0-9]{9}$/,
cyprus: /^[A-z][0-9]{6,8}$/,
czech: /^[0-9]{8}$/,
denmark: /^[0-9]{9}$/,
estonia: /^[A-z][0-9]{7}$/,
finland: /^[0-9]{12}$/,
france: /^[0-9]{2}[A-z]{2}[0-9]{5}$/,
germany: /^[CFGHJK0-9][0-9]{3}[CHJKLMNPRTVWXYZ0-9]{5}[0-9]$/,
hungary: /^[A-z][0-9]{6,7}$/,
ireland: /^[A-z][0-9]{7}$/,
italy: /^[A-z0-9][0-9]{7}$/,
latvia: /^(0[1-9]|[1-2][0-9]|3[0-1])(0[1-9]|1[0-2])[0-9]{2}[0-2][0-9]{4}$/,
lithuania: /^[A-z0-9]{8}$/,
luxemburg: /^[A-z0-9]{8}$/,
malta: /^[0-9]{7}$/,
netherlands: /^[A-z0-9]{9}$/,
poland: /^[A-z]{2}[0-9]{7}$/,
portugal: /^[A-z][0-9]{6}$/,
portugal: /^[A-z][0-9]{6}$/,
romania: /^[0-9]{8,9}$/,
slovakia: /^[A-z][0-9]{7}$/,
slovenia: /^[P][A-z][0-9]{7}$/,
sweeden: /^[0-9]{8,9}$/,
spain: /^[A-z0-9]{2,3}[0-9]{6}$/,
uk: /^[0-9]{8,9}$/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment