[BangPypers] regular expression for Indian landline numbers

Dhananjay Nene dhananjay.nene at gmail.com
Fri Nov 26 04:33:02 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})'
> any clues on how to make it shorter? And any info as to whether my
> assumptions as to the landline numbers is correct?

Not to take away the fun that so many are obviously having on this thread,
but at least from a business perspective what generally matters (barring
some rare exceptions) is that Indian phone numbers are all 10 digits. :)

Thus there could be the optional prefixes +91 or 0 followed by an additional
sequence of numbers which may have embedded some spaces, hyphens or in rare
cases parenthesis which are quite ignorable.

So all one really needs to do (say if one wants to call back) is to extract
one single 10 digit number using the above logic by stripping off the
optional prefixes and the extra characters (which I presume would be quite
trivial). But then maybe my mind is not working well today early morning :)


> regards
> Kenneth Gonsalves
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers

blog: http://blog.dhananjaynene.com
twitter: http://twitter.com/dnene

More information about the BangPypers mailing list