[thelist] Validating Irish Phone Numbers

Keith Gaughan keith at digital-crew.com
Wed Dec 8 14:55:07 CST 2004

James Hardy wrote:

> Hi All,
> I run a site where people registering must give their telephone numbers. 
> Currently the site is open to customers from the UK and Éire.
> Naturally we want some validation of the numbers. For the British 
> numbers this is no problem as we are familiar with the format and have 
> written a set of regular expressions to handle it (see tip). However we 
> don't really have any clear idea of the format of Irish numbers. If 
> there are any Irishmen (or women) on the list, or anyone who just 
> happens to know, could they please help

You wouldn't believe how much Irish phone numbers suck.

You see, unlike more sane telephone companies, Eircom (or rather the
Department of Post and Telegraph, which it was part of when the "system"
was devised) created a rather ad-hoc scheme, the rationale first being
"nobody outside of Dublin is ever going to need a phone", then "nobody
outside of the towns is ever going to need a phone", then "nobody in
Connacht is ever going to need a phone", then "everybody who's ever
going to be getting a line installed already has one", and finally "oh
crap! We really screwed that up!"

The area code can be between two and four digits long. All Dublin
numbers take 01 as an area code, whilst great chunks of the west of the
country, where the first two digits of the area code are 09, take four
digit codes, e.g 0901, 0904.

Everything between 01 and 09 uses three digit codes, for instance 021
(The City of Cork), 072 (part of County Sligo).

The actual phone numbers can range from five digits to seven. This is
in flux right now as they're slowly turning all the five- and six-digit
numbers into seven digit ones. I don't know how many are left, but I'm
pretty sure all of the 09?? numbers are still five digits.

Numbers (generally) don't start with a "1", e.g. 021 4444444. However,
when Vodafone bought Eircell (Eircom's former mobile phone division),
they started to issue mobile phone numbers starting with "1", e.g.
087 1111111. Note though that the second digits of these numbers can't
be "8" or "5"--e.g. 1811111 or 1511111--for reasons I'll explain a bit
later. The mobile area codes are 088 (old analogue), 087 (formerly
Vodafone), 086 (formerly O2), 085 (formerly Meteor). I think there may
have been an 089 area code, but that's well defunct by now. They'll
probably open up the area code range from 080 to 084 soon enough.

System? What system?

Then there's the numbers whose area code starts with "1". These are
Freefone, lo-call, premium, etc. rate numbers. These ones actually
have a sane structure, which is regexable: 1[58]\d\d [1-9]\d{5}

Mind you, knowing this isn't going to be useful to you, seeing as
I don't think you're ever going to be validating these.

I don't envy you. It might be regexable, but not without considerable
pain: I'd write a validation function if I were you, preferably a
data-driven one.


Keith Gaughan, Developer
Digital Crew Ltd., Pembroke House, Pembroke Street, Cork, Ireland.

More information about the thelist mailing list