I want to understand what regular expression means
(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$
Below is what I understand the expression to me. Can you confirm or explain?
(?=^.{8,}$)
string should be 8 character or more
((?=.*\d)|(?=.*\W+))
string should consist of one number or one special character. What is the plus after W?
(?![.\n])
Not sure what this part means.
(?=.*[A-Z])(?=.*[a-z]).*$
My understanding is that $
means end of expression, so it's kinda confusing why there's a dot and an asterisk before it. Also why is there only one $
? Shouldn't it have two: one $
after .*[A-Z]
and one after .*[a-z]
? To say that this section is supposed to make sure that user typed one small and one capital letter?
I am using this code in html form for practice and it's working fine.
All together this regular should achieve this and it's doing it UpperCase, LowerCase, Number/SpecialChar and min 8 Chars
Edit: regex101.com i am also trying to understand on this side as @ymonad said in comment