Go (RE2)

IBAN (International Bank Account Number) in GO

Validate IBAN bank account identifiers: 2-letter country code, 2 check digits, 11–30 alphanumerics.

Try it in the GO tester →

Pattern

regexGO
^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$

Go (RE2) code

goGo
package main

import (
	"fmt"
	"regexp"
)

func main() {
	re := regexp.MustCompile(`^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$`)
	input := `GB29NWBK60161331926819`
	for _, match := range re.FindAllString(input, -1) {
		fmt.Println(match)
	}
}

Uses `regexp.MustCompile` (panics on bad patterns at startup) and `FindAllString` for all matches.

How the pattern works

^[A-Z]{2} matches the ISO country prefix (e.g. DE, GB, FR). \d{2} matches the two-digit check sum. [A-Z0-9]{11,30}$ matches the remaining bank/account portion which varies by country between 11 and 30 characters. This validates structure but does NOT verify the mod-97 checksum — pair with a checksum function for full validation.

Examples

Input

GB29NWBK60161331926819

Matches

  • GB29NWBK60161331926819

Input

DE89370400440532013000

Matches

  • DE89370400440532013000

Input

1234567890

No match

Same pattern, other engines

← Back to IBAN (International Bank Account Number) overview (all engines)