FROM : https://www.cnblogs.com/ilookbo/p/4828722.html
/// <summary> /// 判断输入的字符串是否只包含数字和英文字母 /// </summary> /// <param name="input"></param> /// <returns></returns> public static bool IsNumAndEnCh(string input) { string pattern = @"^[A-Za-z0-9]+$"; Regex regex = new Regex(pattern); return regex.IsMatch(input); }