RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find UK VAT validation
Expression
^(GB)?(\ )?[0-9]\d{2}(\ )?[0-9]\d{3}(\ )?(0[0-9]|[1-8][0-9]|9[0-6])(\ )?([0-9]\d{2})?|(GB)?(\ )?GD(\ )?([0-4][0-9][0-9])|(GB)?(\ )?HA(\ )?([5-9][0-9][0-9])$
Description
UK VAT Validation Conforms to format outlined below: Country code GB followed by either: standard: 9 digits (block of 3, block of 4, block of 2 – e.g. GB999 9999 73) branch traders: 12 digits (as for 9 digits, followed by a block of 3 digits) government departments: the letters GD then 3 digits from 000 to 499 (e.g. GBGD001) health authorities: the letters HA then 3 digits from 500 to 999 (e.g. GBHA599) For the 9-digit scheme, the 2-digit block containing the 8th and 9th digits is always in the range 00 to 96 and is derived from a weighted modulus-97 check number (an identical algorithm is used for the 12-digit scheme, ignoring the extra 3-digit block)
Matches
GB 123 4567 89|123456789 123|GD 123|HA123
Non-Matches
GB 123 4567 97|HA 1234|GB 1234567890
Author Rating: The rating for this expression. Rob Clayton
Source Rob Clayton
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: More Testing
Name: Ash
Date: 2/15/2014 6:26:49 AM
Comment:
....also HA123 does not match


Copyright © 2001-2025, RegexAdvice.com | ASP.NET Tutorials