Skip to content

Instantly share code, notes, and snippets.

@Fedik
Last active April 7, 2026 13:16
Show Gist options
  • Select an option

  • Save Fedik/f050c65fa6cc93973fc65df9d00357f5 to your computer and use it in GitHub Desktop.

Select an option

Save Fedik/f050c65fa6cc93973fc65df9d00357f5 to your computer and use it in GitHub Desktop.
/**
* BIC is the business identifier code (ISO 9362). This BIC check is not a guarantee for authenticity.
*
* BIC pattern: BBBBCCLLbbb (8 or 11 characters long; bbb is optional)
*
* BIC definition in detail:
* - First 4 characters - bank code (only letters)
* - Next 2 characters - ISO 3166-1 alpha-2 country code (only letters)
* - Next 2 characters - location code (letters and digits)
* a. shall not start with '0' or '1'
* b. second character must be a letter ('O' is not allowed) or one of the following digits ('0' for test (therefore not allowed), '1' for passive participant and '2' for active participant)
* - Last 3 characters - branch code, optional (shall not start with 'X' except in case of 'XXX' for primary office) (letters and digits)
*/
function isBic(value) {
return /^([A-Z]{6}[A-Z2-9][A-NP-Z1-2])(X{3}|[A-WY-Z0-9][A-Z0-9]{2})?$/.test( value.toUpperCase() );
}
// Source: jquery-validation/additional/bic.js
@realAlexBarge
Copy link
Copy Markdown

realAlexBarge commented Aug 21, 2018

This solution is not 100% correct. The location code can be letters and digits. The second character can have a meaning (if 0,1 or 2), but all other digits are also valid and indeed are used.

The RegEx therefore has to be changed to: /^([A-Z]{6}[A-Z2-9][A-NP-Z1-9])(X{3}|[A-WY-Z0-9][A-Z0-9]{2})?$/

Commenting since I also found this via search. The source at jquery-validation/additional/bic.js also changed this already.

@Rahul-sinha84
Copy link
Copy Markdown

will the above code work for Euro countries ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment