Validates the local 4 digit phone number with regular expression
//Microsoft Public License (Ms-PL)
//http://c4fdevkit.codeplex.com/license
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace C4F.DevKit.WebServices
{
/// <summary>
/// Provides useful methods like conversion methods.
/// </summary>
public static class Utility
{
/// <summary>
/// Validates the local 4 digit phone number
/// </summary>
/// <param name="phone">Phone number to be validated</param>
/// <returns>True, if phone number is valid</returns>
public static bool ValidateLocalPhoneNumber(string phone)
{
if (String.IsNullOrEmpty(phone))
return false;
return Regex.IsMatch(phone, "^[0-9]{4}$");
}
}
}
Related examples in the same category