public static Boolean IsNameValid(String name, Boolean allowAllCharacters) { name = name.Escape(); Regex reg = new Regex("^[a-zA-Z]*[_]?[a-zA-Z]*$"); if (FilteredNames.Any(filteredName => name.ToLower().Contains(filteredName))) { return(false); } return((reg.IsMatch(name) && !allowAllCharacters) && (name.Length >= 3 && name.Length < 12)); }