C# Regex to allow only alpha numeric

后端 未结 6 389
野的像风
野的像风 2020-12-15 03:45

I have the following regex ^[a-zA-Z0-9]+$ which would allow alpha numeric characters. The problem here is that if I enter only numeric character like \"897687\"

6条回答
  •  醉梦人生
    2020-12-15 04:45

    This function will return true or false based on whether the Regular Expression is matched or not,

       public static Boolean isAlphaNumeric(string strToCheck)
        {
            Regex rg = new Regex(@"^[a-zA-Z0-9\s,]*$");
            return rg.IsMatch(strToCheck);
        }
    

提交回复
热议问题