Sometimes we cannot influence the specifications and have to write the implementation independently, that is, when some old backoffice system needs to be paired over the Internet, but has certain input restrictions, or simply because your boss asks you to.
EDIT: removed the regular expression based on the original regular expression for the crawler.
the source code has been changed to fit your description as it does not seem to really work:
EDIT: q. has been updated to reflect another version. The following differences exist:
My version: two or more \W and \d can repeat each other, but cannot appear next to each other (this was my wrong assumption), I fixed it to a length> 7, which is a little more efficient to place as a typical expression " capture everything. "
^(?!.*((\S)\1|\s))(?=.*(\d.+){2,})(?=.*(\W.+){2,}).{8,}
The new version in the original question: two or more \W and \d allowed to appear next to each other. This version currently supports lengths> = 6, not lengths> 7, as explained in the text.
The current answer, corrected, should be something like that which accepts updated q., My comments on length> 7 and optimization, then it looks like this: ^(?!.*((\S)\1|\s))(?=(.*\d){2,})(?=(.*\W){2,}).{8,} .
Update: your source code does not work, so I changed it a bit. Update: updated answer to reflect changes in the question, spaces are no longer allowed