[BangPypers] regular expression for Indian landline numbers

Anand Balachandran Pillai abpillai at gmail.com
Thu Nov 25 11:26:13 CET 2010


On Thu, Nov 25, 2010 at 3:11 PM, Kenneth Gonsalves <lawgon at au-kbc.org>wrote:

> hi,
>
> on looking at the telephone book, Indian landline numbers have three
> forms
>
> 3 digit STD code followed by 8 digits
> 4 digit STD code followed by 7 digits
> 5 digit STD code followed by 6 digits
>
> the first digit of the STD code has to be 0. The first digit of the
> landline number starts from 1-6. Of course I am not dead sure of the
> starting numbers, but I have seen mobile numbers starting with 9 and 8,
> and I think 7 is also reserved for mobile. I could not find any
> authorative info on this. This is the re:
>
> r'(^0\d{2}[-\s]{1}[1-6]{1}\d{7})|(^0\d{3}[-\s]{1}[1-6]{1}\d{6})|(^0
> \d{4}[-\s]{1}[1-6]{1}\d{5})'
>

It is doable, but you should really use pyparsing for this - this is UGLY !
:)
Meanwhile, let me hack on it.


>
> any clues on how to make it shorter? And any info as to whether my
> assumptions as to the landline numbers is correct?
> --
> regards
> Kenneth Gonsalves
>
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 
--Anand


More information about the BangPypers mailing list