Download Cheat sheet PDF 12 pages · syntax, editors, patterns, Unicode, performance, debugging
Pattern

Regex for EU VAT number

EU VAT registration — 2-letter country + 8–12 alphanumerics.

The EU VAT number regex is ^(AT|BE|BG|CY|CZ|DE|DK|EE|EL|ES|FI|FR|GB|HR|HU|IE|IT|LT|LU|LV|MT|NL|PL|PT|RO|SE|SI|SK)[A-Z0-9]{8,12}$ — copy it below, or open it in the explainer for a token-by-token breakdown.

The pattern

^(AT|BE|BG|CY|CZ|DE|DK|EE|EL|ES|FI|FR|GB|HR|HU|IE|IT|LT|LU|LV|MT|NL|PL|PT|RO|SE|SI|SK)[A-Z0-9]{8,12}$
Try in explainer → Download cheat sheet ↓

What it matches

  • DE123456789
  • FRAB123456789
  • GB123456789

What it doesn't match

  • DE12345
  • XX123456789
  • US123456789

Notes & gotchas

Each member state has its own VAT format, but they all start with the 2-letter country code. The total length varies (DE=11 chars, FR=13, IT=13). Lengths shown are loose; validate with VIES for the strict format.

Code in your language

Use the explainer's Code tab to generate ready-to-paste snippets in JavaScript, Python, Java, .NET, Go, Ruby, and PHP for this pattern.

Open in explainer →

Token-by-token breakdown

Every part of the pattern, left to right:

TokenMeaning
^start of string (or line in multiline mode)
(start of a capturing group
ATliteral text “AT”
|OR — try the alternative
BEliteral text “BE”
|OR — try the alternative
BGliteral text “BG”
|OR — try the alternative
CYliteral text “CY”
|OR — try the alternative
CZliteral text “CZ”
|OR — try the alternative
DEliteral text “DE”
|OR — try the alternative
DKliteral text “DK”
|OR — try the alternative
EEliteral text “EE”
|OR — try the alternative
ELliteral text “EL”
|OR — try the alternative
ESliteral text “ES”
|OR — try the alternative
FIliteral text “FI”
|OR — try the alternative
FRliteral text “FR”
|OR — try the alternative
GBliteral text “GB”
|OR — try the alternative
HRliteral text “HR”
|OR — try the alternative
HUliteral text “HU”
|OR — try the alternative
IEliteral text “IE”
|OR — try the alternative
ITliteral text “IT”
|OR — try the alternative
LTliteral text “LT”
|OR — try the alternative
LUliteral text “LU”
|OR — try the alternative
LVliteral text “LV”
|OR — try the alternative
MTliteral text “MT”
|OR — try the alternative
NLliteral text “NL”
|OR — try the alternative
PLliteral text “PL”
|OR — try the alternative
PTliteral text “PT”
|OR — try the alternative
ROliteral text “RO”
|OR — try the alternative
SEliteral text “SE”
|OR — try the alternative
SIliteral text “SI”
|OR — try the alternative
SKliteral text “SK”
)end of group
[A-Z0-9]{8,12}between 8 and 12 times: any of: uppercase letters, digits
$end of string (or line in multiline mode)

About this pattern

European Union identifiers follow standards set by individual member states with EU-wide coordination (VAT VIES, IBAN/SEPA, etc.). The regex validates structure; for production use, validate via the appropriate registry.

Quick usage in different languages

This exact pattern — with the correct escaping and idioms for each language:

  • JavaScript: /^(AT|BE|BG|CY|CZ|DE|DK|EE|EL|ES|FI|FR|GB|HR|HU|IE|IT|LT|LU|LV|MT|NL|PL|PT|RO|SE|SI|SK)[A-Z0-9]{8,12}$/.test(value)
  • Python: re.match(r"^(AT|BE|BG|CY|CZ|DE|DK|EE|EL|ES|FI|FR|GB|HR|HU|IE|IT|LT|LU|LV|MT|NL|PL|PT|RO|SE|SI|SK)[A-Z0-9]{8,12}$", value)
  • Java: Pattern.compile("^(AT|BE|BG|CY|CZ|DE|DK|EE|EL|ES|FI|FR|GB|HR|HU|IE|IT|LT|LU|LV|MT|NL|PL|PT|RO|SE|SI|SK)[A-Z0-9]{8,12}$").matcher(value).matches()
  • C# / .NET: Regex.IsMatch(value, @"^(AT|BE|BG|CY|CZ|DE|DK|EE|EL|ES|FI|FR|GB|HR|HU|IE|IT|LT|LU|LV|MT|NL|PL|PT|RO|SE|SI|SK)[A-Z0-9]{8,12}$")
  • Go: regexp.MustCompile(`^(AT|BE|BG|CY|CZ|DE|DK|EE|EL|ES|FI|FR|GB|HR|HU|IE|IT|LT|LU|LV|MT|NL|PL|PT|RO|SE|SI|SK)[A-Z0-9]{8,12}$`).MatchString(value)
  • Ruby: /^(AT|BE|BG|CY|CZ|DE|DK|EE|EL|ES|FI|FR|GB|HR|HU|IE|IT|LT|LU|LV|MT|NL|PL|PT|RO|SE|SI|SK)[A-Z0-9]{8,12}$/.match?(value)
  • PHP: preg_match('~^(AT|BE|BG|CY|CZ|DE|DK|EE|EL|ES|FI|FR|GB|HR|HU|IE|IT|LT|LU|LV|MT|NL|PL|PT|RO|SE|SI|SK)[A-Z0-9]{8,12}$~', $value)

The explainer’s Code tab regenerates these for any pattern you paste, and the downloadable cheat sheet bundles the breakdown, all seven snippets, and the pitfalls below onto one printable page.

Common pitfalls

  • Anchored to the whole string. This pattern uses ^ and $, so it requires the entire input to match. To find it inside a longer text, drop the anchors and use the global (g) flag.
  • Uppercase only. Ranges like [A-Z] won't match lowercase. Add a-z (or the i flag) if lowercase input should be accepted.
  • Validate beyond format. Matching the format doesn't guarantee the value is real. Confirm the eu vat number against a source of truth (database, API, or checksum) where it matters.

Standards & sources

This pattern is based on the following authoritative specification(s) and issuing authorities. Formats can change — always confirm against the primary source.

Related patterns

More patterns in the Europe 🇪🇺 category:

See also

Browse all 300 patterns in the library, or open this regex in the interactive explainer for a token-by-token breakdown, live testing, and code in seven languages.


Want more patterns? Browse the full library →