的正则表达式字母数字密码,至少1个数字和字符 [英] Regex for alphanumeric password, with at least 1 number and character

查看:661
本文介绍了的正则表达式字母数字密码,至少1个数字和字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要与字母数字密码正则表达式的帮助,至少有1号和字符,长度必须在8-20个字符之间。



我有这个,但似乎并不奏效(它没有长度要求其一):

  ^ [A-ZA-z0- 9] * [A-ZA-Z] [A-ZA-Z0-9] * $ 


解决方案

如果你看看这个 MSDN链接,它提供了密码验证的正则表达式表达的一个例子,和(更具体地说)如何在ASP.NET中使用它。



有关你要找来完成,这算什么应工作:(?!^ [0-9] * $)?!

 (^ [A-ZA-Z] * $)^([A-ZA-Z0-9] {8,20})$ 

这至少需要一个数字,至少一个字母字符,没有特殊的字符,并从8-20个字符的长度。


Need help with a regex for alphanumeric password, with at least 1 number and character, and the length must be between 8-20 characters.

I have this but doesn't seem to be working (it doesn't have length requirements either):

^[A-Za-z0-9]*[A-Za-z][A-Za-z0-9]*$

解决方案

If you take a look at this MSDN link, it gives an example of a password validation RegEx expression, and (more specifically) how to use it in ASP.NET.

For what you're looking to accomplish, this should work:

    (?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,20})$

This requires at least one digit, at least one alphabetic character, no special characters, and from 8-20 characters in length.

这篇关于的正则表达式字母数字密码,至少1个数字和字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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