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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find OS Grid/Tile Reference
Expression
^(H(P|T|U|Y|Z)|N(A|B|C|D|F|G|H|J|K|L|M|N|O|R|S|T|U|W|X|Y|Z)|OV|S(C|D|E|G|H|J|K|M|N|O|P|R|S|T|U|W|X|Y|Z)|T(A|F|G|L|M|Q|R|V)){1}\d{4}(NE|NW|SE|SW)?$|((H(P|T|U|Y|Z)|N(A|B|C|D|F|G|H|J|K|L|M|N|O|R|S|T|U|W|X|Y|Z)|OV|S(C|D|E|G|H|J|K|M|N|O|P|R|S|T|U|W|X|Y|Z)|T(A|F|G|L|M|Q|R|V)){1}(\d{4}|\d{6}|\d{8}|\d{10}))$
Description
This pattern validates a British Ordnance Survey Grid/Tile/Sheet Reference Number. Information on the range of possible values can be found here: http://www.ordnancesurvey.co.uk/oswebsite/gps/information/coordinatesystemsinfo/guidetonationalgrid/page17.html. Grid Ref, Tile Ref, Sheet Ref.
Matches
NA1234SE
Non-Matches
AA1234SE
Author Rating: Not yet rated. Dan Snellgrove
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: Channel Islands grid refs
Name: Alan Hale
Date: 7/23/2012 7:24:41 AM
Comment:
This regex saved me an awful of head-scratching. It would be very useful if it could also cover the Channel Islands (WV and WA squares. Many thanks


Title: Nice regex but doesn't match the SV square
Name: Mike
Date: 7/14/2009 5:12:02 AM
Comment:
It's a good regex, although it doesn't match the SV square off the Cornish coast.


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