[ENG] Irish Ericode validation regex php, JavaScript

Every address in Ireland will receive its Eircode in Summer 2015. Ireland will be the first country
in the world to have a public database of unique identifiers for all properties which will assist
citizens, businesses and public bodies to locate every individual address in the country.


According to Product guide chapter 1.5.4 allowed signs are:

Component Position Allowed characters
Routing Keys 1 A,C,D,E,F,H,K,N,P,R,T,V,W,X,Y
Routing Keys 2 0-9
Routing Keys 3 0-9 with the exception of W for D6W
Unique Identifier 4 0-9, A,C,D,E,F,H,K,N,P,R,T,V,W,X,Y
Unique Identifier 5 0-9, A,C,D,E,F,H,K,N,P,R,T,V,W,X,Y
Unique Identifier 6 0-9, A,C,D,E,F,H,K,N,P,R,T,V,W,X,Y
Unique Identifier 7 0-9, A,C,D,E,F,H,K,N,P,R,T,V,W,X,Y

Every routing key must contain letter and two digits except ONE specific situation which is D6W code.

So codes begening with A5W, C6W, V0W are invalid.

According to chapter 1.5.1 Recommendations for Storage and Presentation

  • An Eircode should always be stored as a single string of seven upper case characters in IT systems, i.e. A65F4E2.
  • An Eircode should always be presented in upper case as two parts separated by a space, on stationary, mail items, computer forms, etc. i.e. A65 F4E2 and never A65F4E2.
  • Codes stored in database shouldn’t be separated with space or dash, should be separated but only by space and only for displaying.

Correct regex should looks like:

/([AC-FHKNPRTV-Y]\d{2}|D6W)[0-9AC-FHKNPRTV-Y]{4}/

Online regex tester
Ericode guide version 8