Ad
  • Custom User Avatar

    Wow, multiline passwords? Give me two! :D

  • Custom User Avatar

    Thanks for the clarification, I often forget that.

  • Custom User Avatar

    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 end

    Anyone 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.

  • Custom User Avatar

    I didn't know about those lookaheads, that's pretty powerful. Thank you for taking the time to write that down. :)

  • Custom User Avatar

    Whoops, meant to reply to you. See above ^

  • Custom User Avatar

    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 match abbc or abbbc, but not abc or abbbbc.

    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,}$

  • Custom User Avatar

    Can someone explain in detail this one?

  • Default User Avatar

    are you Chinese?