static string CapText(Match m) { // Get the matched string. string x = m.ToString(); // If the first char is lower case... if (char.IsLower(x[0])) { // Capitalize it. return char.ToUpper(x[0]) + x.Substring(1, x.Length - 1); } return x; } private void giveFormatSuggestion() { bool isStudentFirstNameSuggestionShow = !System.Text.RegularExpressions.Regex.IsMatch(txt_student_first_name.Text.Trim(), @"^[A-Z]'?[- a-zA-Z]( [a-zA-Z])*$"); if (isStudentFirstNameSuggestionShow) { p_student_first_name_suggestion.Visible = true; lbl_student_first_name_suggestion.Text = replaceFirstCharWithCapital(txt_student_first_name.Text); if (lbl_student_first_name_suggestion.Text.Equals(txt_student_first_name.Text)) { p_student_first_name_suggestion.Visible = false; lbl_student_first_name_suggestion.Text = ""; } } else { p_student_first_name_suggestion.Visible = false; lbl_student_first_name_suggestion.Text = ""; } }