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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Combined UK Vehicle Registration
Expression
^([A-Z]{3}\s?(\d{3}|\d{2}|d{1})\s?[A-Z])|([A-Z]\s?(\d{3}|\d{2}|\d{1})\s?[A-Z]{3})|(([A-HK-PRSVWY][A-HJ-PR-Y])\s?([0][2-9]|[1-9][0-9])\s?[A-HJ-PR-Z]{3})$
Description
UK vehicle registration system. This is the obvious combination of two previous expressions posted here, to merge the older system with the current system.
Matches
ABC 123 A | A 123 ABC | AB 12 ABC
Non-Matches
AB 123 C | A 123 AB | AB 12 AB
Author Rating: Not yet rated. Amos Hurd
Source
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: Error in regex. Plus doesn't cover dateless plate formats
Name: Pete
Date: 10/8/2013 6:27:40 AM
Comment:
The regex is missing a \ in the first '(\d{3}|\d{2}|d{1})' so ABC1D won't match, but weirdly it will match ABCdD. That chunk should be '(\d{3}|\d{2}|\d{1})', or maybe preferably '(\d{1,3})'. Dateless formats aren't matched, just so people are aware. (personalised plates, originally issued pre 1963)


Title: Not suitable for strict validation
Name: Andy
Date: 5/30/2008 9:49:38 AM
Comment:
I've found this RegEx to not be strict enough for validation, for example, it validates this valid registration: AB12 ABC But, if I add additional characters e.g.: AB12 ABCDEF The expression will still match on a subset of these characters: A[B12 ABC]DEF So there is huge potential for validating invalid car registrations.


Title: Not suitable for strict validation
Name: Andy
Date: 5/30/2008 9:49:23 AM
Comment:
I've found this RegEx to not be strict enough for validation, for example, it validates this valid registration: AB12 ABC But, if I add additional characters e.g.: AB12 ABCDEF The expression will still match on a subset of these characters: A[B12 ABC]DEF So there is huge potential for validating invalid car registrations.


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