In: Computer Science
PROC TELEPHONE_NUMBER
postproc
  if regexmatch(TELEPHONE_NUMBER,
"^([0-9]{3}-){2}[0-9]{4}$") = 0 then
  errmsg("Invalid format! Use the following format:
xxx-xxx-xxxx.");
  reenter;
  endif;
OR
<asp:regularexpressionvalidator validationexpression="”\d{3}-\d{3}-\d{4}”ControlToValidate=”txtPhone”" id="”RegExpVal_txtPhone”" runat="”server”" errormessage="”Invalid" format="" (="" use:="" xxx-xxx-xxxx)”="" display="”Dynamic”"></asp:regularexpressionvalidator>
code in action, run the example
protected bool
IsValidPhone(string strPhoneInput)
{
   // Remove
anything that is not a number
   string
strPhone = Regex.Replace(strPhoneInput, @"[^\d]",
String.Empty);
   txtPhone2.Text =
strPhone;
   // Check
for exactly 10 numbers left over
   return
(strPhone.Length == 10);
}
