Title: Bad
Name: J
Date: 3/6/2019 3:35:05 PM
Comment:
This regex is terrible ([GB])* means 0 or more "G or "B".
This not only matches GB, but BG aswell, and even GBBGBGBGBGBGBGBGBGBG.
And lord only knows what the rest of the regex is doing. If a valid VAT number has either 9 or 12 digits, why are you checking for 8 and 11? It's not zero indexed.
This is a much better regex:
^(GB)?([0-9]{9}|[0-9]{12})$
Title: improvement on the base version
Name: Fabrizio Moscon
Date: 1/7/2013 7:19:34 AM
Comment:
^(GB)?([0-9]{9}|[0-9]{12}|(GD|HA)[0-9]{3})$
# Standard
'123456789',
'GB123456789',
'GB999 9999 73',
# Branch Traders
'123456789123',
'GB123456789123',
# Govt Departments
'GD999',
'GBGD999',
# Health Authorities
'HA999',
'GBHA999',
# Tesco
'GB220430231'
Title: EC Vat Number Layout
Name: Giles Hyde
Date: 11/12/2010 4:33:30 AM
Comment:
Very useful - many thanks :)
Title: EC Vat Number Layout
Name: Geoff Tyrer
Date: 1/12/2010 8:06:27 AM
Comment:
The EC has created a Taxation and Customs web site and this provides the VAT Number layout specifications of all EC countries. At the time of writing it can be found at: http://ec.europa.eu/taxation_customs/vies/faqvies.do#item14 - scroll down to Question 11.
The layout specification they give for the UK is:
GB999 9999 99 (regular)
GB999 9999 99 999 (branch traders)
GBGD999 (government departments
GBHA999 (health authorities)
Geoff Tyrer
ViziGenHC
Title: EC Vat Number Layout
Name: Geoff Tyrer
Date: 1/12/2010 8:03:44 AM
Comment:
The EC has created a Taxation and Customs web site and this provides the VAT Number layout specifications of all EC countries. At the time of writing it can be found at: http://ec.europa.eu/taxation_customs/vies/faqvies.do#item14 - scroll down to Question 11.
The layout specification they give for the UK is:
GB999 9999 99 (regular)
GB999 9999 99 999 (branch traders)
GBGD999 (government departments
GBHA999 (health authorities)
Geoff Tyrer
ViziGenHC
Title: EC Vat Number Layout
Name: Geoff Tyrer
Date: 1/12/2010 8:03:29 AM
Comment:
The EC has created a Taxation and Customs web site and this provides the VAT Number layout specifications of all EC countries. At the time of writing it can be found at: http://ec.europa.eu/taxation_customs/vies/faqvies.do#item14 - scroll down to Question 11.
The layout specification they give for the UK is:
GB999 9999 99 (regular)
GB999 9999 99 999 (branch traders)
GBGD999 (government departments
GBHA999 (health authorities)
Geoff Tyrer
ViziGenHC
Title: Ooops!
Name: Ben Powell
Date: 12/6/2005 6:38:11 AM
Comment:
Sorry that should be:
^([GB])*(([1-9]\d{8})|([1-9]\d{11}))$
Apologies, got my digits counts wrong. Indexing starts at ZERO!
Title: Minor UK VAT format styles
Name: Ben Powell
Date: 12/6/2005 6:06:00 AM
Comment:
Colin Perry is indeed correct. As well as this, the VAT number should be prefixed by GB.
The UK format for VAT numbers also includes seperate formats for branch traders (GB123 4567 89 123), government departments and health authorities.
^([GB])*(([1-9]\d{9})|([1-9]\d{12}))$
The regex above would cure the basic woes, though I am guessing that Customs & Excise could be strict on the spacing too. The above example does not provide for the other minor formats.
Title: Doesn't catch all UK VAT nos
Name: Colin Perry
Date: 3/12/2005 12:17:04 PM
Comment:
Works well... but a few UK VAT numbers are 12 digits long.