Skip to content

Instantly share code, notes, and snippets.

@marcusandre
Last active December 11, 2018 09:23
Show Gist options
  • Save marcusandre/531b823aca830aff4eb7e6af86fa6bfb to your computer and use it in GitHub Desktop.
Save marcusandre/531b823aca830aff4eb7e6af86fa6bfb to your computer and use it in GitHub Desktop.
IBAN regular expressions

IBAN regular expression

The following regular expression will match:

  • AB12 1234 1234 1234 1234
  • AB12 1234 1234 1234 1234 1
  • AB12 1234 1234 1234 1234 12

but also:

  • AB123456789012345678
  • AB1234567890123456789
  • AB12345678901234567890
^[A-Z]{2}(?:[ ]?[0-9]){18,20}$

If you also need to match IBAN formats by country (BBAN Format), use:

^([A-Z]{2}[ \-]?[0-9]{2})(?=(?:[ \-]?[A-Z0-9]){9,30}$)((?:[ \-]?[A-Z0-9]{3,5}){2,7})([ \-]?[A-Z0-9]{1,3})?$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment