Validating UK phone number (Regex C#)

后端 未结 5 883
既然无缘
既然无缘 2021-02-06 05:18
public static bool ValidatePhoneNumber(string number)
{
    return Regex.Match(number, \"^(\\+44\\s?7\\d{3}|\\(?07\\d{3}\\)?)\\s?\\d{3}\\s?\\d{3}$\", RegexOptions.Ignore         


        
5条回答
  •  时光取名叫无心
    2021-02-06 05:31

    This works well and allows 3 and 4 digit extensions. It also ensures that only mobile numbers are entered. UK mobile numbers start with 07 regardless of the provider

    ^(\+44\s?7\d{3}|\(?07\d{3}\)?)\s?\d{3}\s?\d{3}(\s?\#(\d{4}|\d{3}))?$
    

提交回复
热议问题