Ad
  • Custom User Avatar

    Ac10y can't be returned as A11y. "A c10(3 characters) y" = A3y. To get A11y you would have to type "Accessability". No math is being done within the regex. Take any string "234543"(243) "hello"(h3o) "234fvj9"(259) and you will get the first and last chars and the number of chars in between. If Ac10y didn't return A3y the test would fail.

    To put it simply the regex says (\w)= give me first character. (\w+{2}) = give me exactly 2 characters multiple times (this should actually be (\w\w+) or (\w{2,}) to guarantee 2 or more letters in between) and the last (\w) = give me the final character(if this wasn't used, the final character would be matched in the second group, this pulls the final character from it.

    Groupings are selfish. They take as much as they can and only leave enough for the next groupings. Take "accessability" and do (\w+)(\w+)(\w+) this will split the word up into three parts, but it won't be even. the first group will take all 11 chars and the next two groups will each get one letter. "accessibili" "t" "y". So it's important to force which groups will be selfish. (\w)(\w+)(\w) (this grouping doesn't work for the test because it would match 3 letter words) which is why we came up with (\w)(\w\w+)(\w)

    Sorry so long.

  • Custom User Avatar

    This is the best one.

  • Custom User Avatar

    So, I take it you can't learn a language here, you have to already know one...