Regular expression (RegEx) for phone numbers with country code verification

I need PHP RegEx through which I can check the phone number format using the following criteria:

  • Nothing but numbers should be included;
  • You should not start from scratch, as I need the country code to be a prefix;
  • The list of allowed country codes must be in RegEx;
  • The number immediately after the country code should not be zero;
  • The maximum number length must not exceed 13 digits.

I tried to do a search in Qaru before posting this question, but could not find the exact solution. Any help would be greatly appreciated.

Edit: I just want the user to enter a phone number in a valid format , as my clients are currently making some silly formatting errors when writing. I am not worried that this is really call-able, since the user will take care of it.

Hi

+5
source share
2 answers

I would not burn fingers on this.

Just by looking at the phone number, you cannot judge whether it is valid or not, and even if it "looks" valid, it may not be the phone number you are looking for (for example, the phone number of another user).

. - ;)

, :

/^(1|20|21|..etc)[1-9][0-9]+$/

( |), , 0, .

13 , ( ). 13 , :

/^.{,13}$/

13

+5

;

. 0 - .

, , .

13 .

, , .

3- , 3- 8- , .

+3

All Articles