正则表达式密码策略 [英] Regex for password policy

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

问题描述

我需要执行以下密码策略:

I need to enforce the following password policy :

至少9个字符,4个字符中的至少1个字符 字符类(字母的大小写;数字,符号).

at least 9 characters, with at least one character from each of the 4 character classes (alphabetic lower and upper case; numeric, symbols).

任何正则表达式专家都可以在这里提供帮助吗? (我正在使用Java regex引擎)

Any regex experts can help out here ? (I am using a Java regex engine)

在使用的同时,是否有任何在线工具可以为此类任务生成正则表达式?

While we're at it, is there any online tool that can generate a regex for these kind of tasks ?

谢谢!

推荐答案

(?=.{9,})(?=.*?[^\w\s])(?=.*?[0-9])(?=.*?[A-Z]).*?[a-z].*

请注意,此模式不包括特殊的utf字符,例如ö.我不会在一个正则表达式中做到这一点.如果您想验证它,我将其拆分并搜索每件事.

Note that this pattern doesn't include special utf chars like ö. I would not do this in one regex. I would split it and search for each thing, if you want to validate it.

这篇关于正则表达式密码策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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