using System;
using System.Text.RegularExpressions;
class RegexSubstitution
{
public static void Main()
{
string text = "124";
if ( !Regex.Match(text,@"^[1-9]\d{2}-[1-9]\d{2}-\d{4}$" ).Success )
{
Console.WriteLine( "Invalid phone number");
}
}
}
public bool IsValidUSPhone(string number)
{
return Regex.IsMatch(number, @"\(\d{3}\)\s\d{3}-\d{4}");
}