Code:Regex regex = new Regex(@"^(\s)*(\d ){6}\d(\s)*$");//note there's a blank space after the first '\d' bool isValid = true; string[] ts = textBox1.Text.Split(new string[]{"\r\n"}, StringSplitOptions.RemoveEmptyEntries); if (ts == null || ts.Length < 1) { isValid = false; } else { foreach (string t in ts) { if (regex.IsMatch(t) == false) { isValid = false; break; } } } if (isValid) { //do sth. }




Reply With Quote
