feiyucha

实现效果:

 

关键知识:

  Regex类的IsMatch方法用于指示正则表达式使用的patterm参数中指定的正则的表达式是否在输入字符中找到匹配项

  public static bool IsMatch(string input,string pattem)

实现代码:

        private void button1_Click(object sender, EventArgs e)
        {
            if(IsPassWord(textBox1.Text.ToString())){
                MessageBox.Show("输入正确", "提示");
            }else{
                MessageBox.Show("验证失败,请重试", "提示");
            }
        }
        public bool IsPassWord(string str_password)
        {
            return System.Text.
                RegularExpressions.Regex.
                    IsMatch(str_password,@"[a-zA-Z]+[0-9]");
        }

补充说明:

  不是随便的字母数字组合都可以,要符合字母在前的原则

分类:

技术点:

相关文章:

  • 2021-11-29
  • 2021-12-02
  • 2022-01-01
  • 2021-12-23
  • 2021-12-24
  • 2021-11-20
  • 2022-01-06
  • 2021-11-30
猜你喜欢
  • 2021-12-11
  • 2021-12-23
  • 2021-12-25
  • 2022-01-07
  • 2022-02-09
  • 2021-12-13
相关资源
相似解决方案