New Zealand Dialing validation regex

, posted: 10-Sep-2018 16:10

Was doing some work with the NZ Dialing plan and needed to write some regex to validate NZ numbers. This is what I ended up with

^0[34679][\d]{7}$|^020[1-6][\d]{6,7}$|^0210[03-7][\d]{5}$|^021[12][\d]{6}$|021[3-9][\d]{5}$|^02[279][\d]{7}$|^028[\d]{6,8}$
 
Local area codes 03,04,06,07,09 are all 8 digits long including the 0
 
Mobiles 0201 to 0206 are either 10 or 11
Mobiles 0211 and 0212 are 10
Mobiles 0213 to 0219 are 9 
Mobiles 022, 027 and 029 are 10
Mobiles 028 are 9 to 11 digits
 
I could be wrong here, but that was my understanding. Feel free to comment on the above if any of it is incorrect.






BarTender's profile

Bar Tender
Wellington
New Zealand