更改密码控制正则表达式仅在 IE 7 中奇怪地验证

发布于 2024-08-26 09:15:47 字数 506 浏览 3 评论 0原文

我在应用程序中使用 Asp.net 更改密码控件,一切似乎都很顺利,直到用户告诉我她在更改密码时无法满足强度要求。对此,她使用的是 IE 7,无论输入什么,验证都会失败(并且仅在 IE 7 中。Firefox、IE 8、Chrome 等都按预期工作)。这是我正在使用的正则表达式:

^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).{5,15}$

我尝试了在本网站中找到的其他一些正则表达式,以及人们似乎使用的其他正则表达式,但我遇到了同样的问题。

看来我在最后输入的任何模式(数字、上限或下限 alpha)预计都会重复至少 5 次。例如:

Hello1 (不起作用)

11111Hello (不起作用)

Hello11​​111 (起作用)

同样,这仅在 IE 7 中有效我已经在这上面花了太多时间了,而且我很困惑。有人有什么想法吗?

I'm using the Asp.net change password control in my application and all seems to be find and dandy until a user tells me she has a problem meeting the strength requirements when changing her password. Looking into this, she is using IE 7 and no matter what she puts in, the validation fails (and ONLY in IE 7. Firefox, IE 8, Chrome etc. all work as expected). Here is the regex i'm using:

^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).{5,15}$

I've tried out a few others that I've found throughout this site and others that folks seem to be using with no issues and I come across the same problem.

It seems that which ever pattern I enter in last (digit, upper or lower alpha) is the one that is expected to be repeated min of 5 times. For example:

Hello1 (doesn't work)

11111Hello (doesn't work)

Hello11111 (works)

Again, this is ONLY in IE 7. I've spent too much time on this already and I'm stumped. Anybody have any ideas??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光无声 2024-09-02 09:15:47

显然 Internet Explorer 有一个错误。查看这篇文章:JScript/VBScript Regex Lookahead Bug。该示例是相同的 - 密码检查 - 他们提供了一种解决方法。使用他们建议的方法作为指导,模式变为:

^(?=.{5,15}$)(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*

他们的模式与您的模式非常相似,除了对空白的负面环顾之外。


Try using .* in the look-arounds. Using just . only covers one character followed by whatever you're specifying in the look-arounds. You want to look all the way ahead and see if anything matches. I tried the following expression in Expresso and it worked with the samples you listed and also failed on invalid inputs as expected.

^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).{5,15}$

Apparently Internet Explorer has a bug. Check out this post: A JScript/VBScript Regex Lookahead Bug. The example is the same - a password check - and they provide a work-around. Using their suggested approach as a guide, the pattern becomes:

^(?=.{5,15}$)(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*

Their pattern is very similar to yours, except for the negative look-around for whitespace.


Try using .* in the look-arounds. Using just . only covers one character followed by whatever you're specifying in the look-arounds. You want to look all the way ahead and see if anything matches. I tried the following expression in Expresso and it worked with the samples you listed and also failed on invalid inputs as expected.

^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).{5,15}$
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文