Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Wow, multiline passwords? Give me two! :D
Thanks for the clarification, I often forget that.
Some of what you say here is wrong, but apparently a lot of people think
^
and$
match string start and end. They match LINE start and endAnyone who accept the above as a valid solution or even worse a "best practise" should think about what happens when someone puts in a multi line password.
I didn't know about those lookaheads, that's pretty powerful. Thank you for taking the time to write that down. :)
Whoops, meant to reply to you. See above ^
The
?=
in(?=pattern)
is called a 'positive lookahead'.The lookahead is non-capturing, so it ensures that the pattern exists, but it doesn't include the pattern in the final match. The
.*
part in each of the lookahead groups matches any character, and it is necessary because it allows all three lookahead groups to match, regardless of the order in which they occur.After the presence of an uppercase letter, a lowercase letter, and a number has been confirmed, the capturing portion of the regex begins. The
^
matches the beginning of the string, the$
matches the end of the string, and the{6,}
part matches a minimum of 6 characters. This syntax takes the form{min, max}
, and matches on the preceding group. For example,/ab{2, 3}c/
would matchabbc
orabbbc
, but notabc
orabbbbc
.So for the solution to this kata,
^[a-zA-Z0-9]{6,}$
matches any string that is at least 6 characters long and contains only alphanumeric characters. There is no maximum number of characters. The preceding lookahead groups ensure that there is at least one character in each group (lowercase, uppercase, and number). The lookahead groups act as a prerequisite, and are discarded when considering the final match, which corresponds to^[a-zA-Z0-9]{6,}$
Can someone explain in detail this one?
are you Chinese?