需要使用Regex.IsMatch的帮助 [英] Need help using Regex.IsMatch

查看:89
本文介绍了需要使用Regex.IsMatch的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试比较在Windows窗体上的文本框中输入的字符串,因为文本更改了,表示密码强度的复选框将被选中还是取消选中.

它可以很好地处理文本长度并可以正确更新,但是在与密码进行比较以查看密码中是否包含特殊字符(例如&,#,$,_等)等时,它可以正常工作.使用Regex.IsMatch不能正确更新,这是我正在使用的代码的一部分.

请告诉我这看起来是否正确?

I am trying to compare a string that is entered into a textbox on windows form as the text changes the checkboxes that represent the password strength will either check or uncheck.

It works fine for the the text length and updates properly but when compared to see if the password contains special characters such as &,#,$,_ etc.etc. using Regex.IsMatch it does not properly update here is part of the code I''m using.

Please tell me if this looks right?

if (password.Length <= 3)
            {                
                if (Regex.IsMatch(password, @"/.[!,@,#,$,%,^,&,*,?,_,~,-,£,(,)]/", RegexOptions.ECMAScript))
                    {
                        Security = (SecurityLevel.Unsecure);
                        
                    }
                    else
                    {
                        Security = (SecurityLevel.None);
                    }
                }

推荐答案

,_等.使用Regex.IsMatch不能正确更新,这是我正在使用的代码的一部分.

请告诉我这看起来是否正确?

,_ etc.etc. using Regex.IsMatch it does not properly update here is part of the code I''m using.

Please tell me if this looks right?

if (password.Length <= 3)
            {                
                if (Regex.IsMatch(password, @"/.[!,@,#,


,%,^,&,*,?,_,〜,-,£,(,)]/",RegexOptions .ECMAScript)) { 安全=(SecurityLevel.Unsecure); } 其他 { 安全=(SecurityLevel.None); } }
,%,^,&,*,?,_,~,-,£,(,)]/", RegexOptions.ECMAScript)) { Security = (SecurityLevel.Unsecure); } else { Security = (SecurityLevel.None); } }


尝试此链接是否要为用户重新串入以输入特殊字符

限制用户输入特殊字符 [
try this Link is you want to restring the User to enter Special characters

Restrict user to Enter special characters[^]


这篇关于需要使用Regex.IsMatch的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆