【问题标题】:Regex for 1 uppercase 1 special character and 1 lowercase [duplicate]1个大写1个特殊字符和1个小写的正则表达式[重复]
【发布时间】:2016-02-13 17:50:45
【问题描述】:

我需要 1 个大写 1 个特殊字符和 1 个小写的正则表达式 注意需要允许所有特殊字符,长度应在8个字符以上。

我试过/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/ 这个,但这限制了一些特殊字符。

【问题讨论】:

标签: regex


【解决方案1】:

尝试使用这个正则表达式:

^(?=.{8,})(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+*!=]).*$

REGEX DEMO

说明:

(/^
(?=.{8,})                //should be 8 characters or more
(?=.*[a-z])             //should contain at least one lower case
(?=.*[A-Z])             //should contain at least one upper case
(?=.*[@#$%^&+*!=])      //should contain at least 1 special characters
.*$/)

【讨论】:

  • 正则表达式演示的精彩解释和使用! +1 谢谢!我的实用工具库中的一个新站点
  • @Madivad:- 不客气!
【解决方案2】:

我会使用:

^(?=.{8,})(?=.*[a-z])(?=.*[A-Z])(?=.*[^\w\d]).*$

注意[^\w\d] 允许any 特殊字符。

【讨论】:

  • 这将需要任何特殊字符。谢谢!
猜你喜欢
  • 1970-01-01
  • 2011-01-22
  • 1970-01-01
  • 2013-01-28
  • 1970-01-01
  • 2012-09-28
  • 1970-01-01
  • 1970-01-01
  • 2012-11-10
相关资源
最近更新 更多