[英]How to get a regular expression based on the following constraints
I need help in creating regex based on the following constraints for creating a password.我需要帮助来根据以下创建密码的约束来创建正则表达式。 [This is for a course assignment]
[这是一个课程作业]
Note : I can't use extended regular expression.注意:我不能使用扩展正则表达式。 I need to use core regex,ie, { |
我需要使用核心正则表达式,即 { | , * , () }
, * , () }
This is my working so far : \\这是我到目前为止的工作: \\
A = { English letters **union** Digits } \
B = { Lowercase letters **union** Digits } \
C = { Uppercase letters **union** Digits } \
D = { Special characters } \
Regex = A(A)* ( B(B)* C(C)* D(D)* )
I can think of a way to solve all the requirements excluding the last one:我可以想出一种方法来解决除最后一个之外的所有要求:
A = { English letters **union** Digits }
B = { Lowercase letters }
C = { Uppercase letters }
D = { Digits }
E = { Special characters }
F = { Union of all allowed characters }
Then you need to spell out all the possible permutations:然后你需要拼出所有可能的排列:
A (BB* CC* DD* EE* | BB* CC* EE* DD* | BB* DD* CC* EE* | BB* DD* EE* CC* | ...) F*
But if you want to add the "no more than three identical digits" rule, I don't see a way around spelling out all those possibilities as well (and do it 24 times for each permutation), which makes it clear why this is not something you want to do with "core regex"...但是如果你想添加“不超过三个相同数字”的规则,我看不出有办法把所有这些可能性都拼出来(并且对每个排列都做 24 次),这就很清楚为什么会这样了不是你想用“核心正则表达式”做的事情......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.