Does anyone know a regular expression for checking MSISDN format mobile numbers?

Does anyone know a regular expression for checking mobile numbers in MSISDN format?

I looked at the solution posted at http://charlvn.blogspot.com/2010/06/msisdn-regular-expressions.html, but I think this is not a general solution.

I am looking for a validation regular expression that can validate any MSISDN mobile number. http://en.wikipedia.org/wiki/MSISDN

Secondly, I’m looking for a way to check if a valid MSISDN mobile number is from a certain country, for example, ā€œ31628000000ā€ is a number from the Netherlands because it starts with network number ā€œ31ā€.

I am going to implement the test part in Python.

Thank you in advance!

+6
source share
3 answers

This should be done - I'm not sure how much more general you can get:

/^[1-9][0-9]{10,14}$/ 

To check the number belonging to a specific country, change the template for the preface of 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 
+11
source
  /^[1-9][0-9]{10,14}$/ 

The shortest international phone number is only 7 digits long, for example. +247 2468.

  /^[1-9]\d{6,14}$/ 
+3
source

so after many years this message appeared on the network, did anyone have a chance to write this code that checks all numbers in the world with the appropriate country codes?

Love to get your help Haim

0
source

Source: https://habr.com/ru/post/1337200/


All Articles