Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.8k views
in Technique[技术] by (71.8m points)

关于正则表达式断言的一些问题?求大佬帮忙解答一下,谢谢

/^(?=.*[a-z])[^s]{8,16}这个正则表达式我理解的意思是
匹配以“任意字符连着一个小写字母”开头的数字,只匹配非空字符,字符长度在8-16之间。

^(?=.*[a-z])(?=.*[A-Z])(?=.*d)([^s]){8,16}$如果是这个多个断言正则,代表的意思是什么呢?我有点晕,希望大佬帮我理顺一下,谢谢


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

/^(?=.*[a-z])[^s]{8,16}$/匹配字符串都规则是:

  1. 只匹配非空字符,且字符长度在8-16之间;
  2. 必须含有小写字母。
    (?=.*[a-z])表达都含义是必须含有小写字母

/^(?=.*[a-z])(?=.*[A-Z])(?=.*d)([^s]){8,16}$/匹配字符串都规则是

  1. 只匹配非空字符,且字符长度在8-16之间;
  2. 必须含有字母;

    • (?=.*[a-z])
    • (?=.*[A-Z])
  3. 必须含有数字。

    • (?=.*d)

课外阅读JS-RegExp函数


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...