Regex for EU VAT Number
Regex Pattern
^[A-Z]{2}\d{2,12}$EU VAT identification number (country code + digits)
Quick Answer
The regex pattern for eu vat number is `^[A-Z]{2}\d{2,12}$`. EU VAT identification number (country code + digits). This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.
Test Examples
| Input | Result |
|---|---|
| DE123456789 | ✓ Matches |
| FR12345678901 | ✓ Matches |
| GB123456789 | ✓ Matches |
| 123456789 | ✗ No match |
| D123456789 | ✗ No match |
| DE1 | ✗ No match |
Code Examples
javascript
const regex = /^[A-Z]{2}\d{2,12}$/;
const isValid = regex.test(value);python
import re
pattern = r'^[A-Z]{2}\d{2,12}$'
if re.match(pattern, value):
print("valid")ruby
pattern = /^[A-Z]{2}\d{2,12}$/
if value =~ pattern
puts "valid"
endphp
if (preg_match('/^[A-Z]{2}\d{2,12}$/', $value)) {
echo "valid";
}java
String pattern = "^[A-Z]{2}\\d{2,12}$";
boolean isValid = value.matches(pattern);Frequently Asked Questions
Related Regex Patterns
UUID v4
UUID version 4 (randomly generated)
UUID (Any Version)
Any RFC 4122 UUID (versions 1-5)
JWT Token
JSON Web Token (header.payload.signature)
Hex String
Any-length hexadecimal string
Base64 String
Standard base64 encoded string
Alphanumeric Username
Username with letters, digits, underscores (3-16 chars)