Telephone number format should be international,Is there any Regex for phone number validation in iPhone

后端 未结 1 1986

Telephone number should be international and user has to enter the complete phone number with country code.

For that I need a regex for formatting the phone number.

1条回答
  •  灰色年华
    2021-01-07 14:07

    For real regex testing use RegexKitLite.

    As for the regular expression itself, something like this (from Validate Phone Numbers: A Detailed Guide) should work:

    ^\+(?:[0-9] ?){6,14}[0-9]$
    

    Note that when you specify it in your code you need to escape the backslash character (\), so it would look like this:

    NSString *regexString = @"^\\+(?:[0-9] ?){6,14}[0-9]$";
    

    0 讨论(0)
提交回复
热议问题