Hi Ganapatisb,
These are the regular expressions:
111-111-1111: ^\d{3}-\d{3}-\d{4}$
11-111-111-1111 : ^\d{2}-\d{3}-\d{3}-\d{4}$
The code snippet below shows how to use them:
private bool IsValid(string input)
{
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(
@"^\d{3}-\d{3}-\d{4}$", System.Text.RegularExpressions.RegexOptions.Compiled);
if (reg.Match(input).Success)
return true;
else
return false;
}
You can get more about regular expressions from:
http://msdn.microsoft.com/en-us/library/2k3te2cs(VS.80).aspx
http://www.codeproject.com/KB/string/re.aspx
Let me know if this helps or not.
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.