"^\d{5}$"
// To enable you to use RegularExpressions // namespace's Classes like Regex & Match. using System.Text.RegularExpressions;
// public static Match Match(string input,string pattern); // this is the parameter of the Match method in Regex Class, // this method returns a referenc to Match Class // so that we can access its properties and methods // through this reference. Match MyRegMatch = Regex.Match(txtName.Text,"^[A-Z]+[a-zA-Z]*$") // using Success property in Our Match object to // check if the match occure or not. if(!MyRegMatch.Success) { //Name was incorrect Cause no Match occur MessageBox.Show("Invalid First Name", "Error",MessageBoxButtons.OK,MessageBoxIcon.Error); txtName.Focus(); return; }
"^[0-9]+\s+([a-zA-z]+|[a-zA-z]+\s+[a-zA-z]+)$"
Build Your Own ASP.NET Website Using C# & VB.NET