Does anyone know a regular expression to validate MSISDN-format mobile numbers?
I looked into a solution posted at http://charlvn.blogspot.com/2010/06/msisdn-regular-expressions.html but I think that's not a generic solution.
I'm looking for a validation regex that could validate any MSISDN-standard mobile number. http://en.wikipedia.org/wiki/MSISDN
Secondly, I'm looking for the means to check whether a valid MSISDN mobile number is from a specific country, like "31628000000" is a number from the netherlands, because it starts with the netnumber "31".
I'm going to implement the validating part in Python.
Thanks in advance!
/^([+]\d{2})? \d{10}$/ This is how this regex for mobile number is working. + sign is used for world wide matching of number.
On a cellular network, MSISDN (Mobile Station Integrated Services Digital Network) is the phone number which identifies a device during calls or data sessions. It performs a crucial function in ensuring secure connectivity between the different components within an IoT network.
This should do -- I'm not sure how much more generic you can get:
/^[1-9][0-9]{10,14}$/
To check a number to belong to a particular country, modify the pattern to preface the country code, and then adjust the remaining digits to match:
/^(873[1-9][0-9]{7,11}|91[1-9][0-9]{8,12})$/ # India
/^46[1-9][0-9]{8,12}$/ # Sweden
/^[1-9][0-9]{10,14}$/
The shortest international phone number is only 7 digits long, e.g. +247 2468.
/^[1-9]\d{6,14}$/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With