[thelist] Validating Irish Phone Numbers

James Hardy evolt at weeb.biz
Thu Dec 9 04:07:06 CST 2004

Keith Gaughan wrote:
> 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.
> K.
Argh, and there was I hoping for some semblance of sanity.

Unfortunately I don't really want to do a full routine, while we are 
only covering the two nations at the moment, We will probably be doing 
more and I don't fancy doing 200 odd functions. So unless it all becomes 
too much, I will stick with a regex for each number format.

 From what you are saying I think /0[1-9][0-9]{5,9}/ would include all 
valid numbers (I know it would include many many invalid ones but at the 
moment I am doing no validation at all for Irish numbers and I would 
accept "rhubarb" as a legit number. So any validation is better than 
none). Is that right?

Likewise would /08[0-9]{5,9}/ include all valid mobile numbers?



More information about the thelist mailing list