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.
This comment is hidden because it contains spoiler information about the solution
The regex used here: /^(.*?)\1+$/
basically means : match a string that starts with any characters (that should be repeated as few times as possible) and put that inside of a group. This group can be repeated 1 or more times until the string ends.
I assume you got confused by the '*?' the asterisk means 0 or more times and the following '?' makes this expression lazy - means match as few characters that follow the pattern as possible.
the '\1' refers to the pattern of the matched group, which can be repeated 1 or more times.
This way he matches the shortest pattern that is repeated through the entirety of the string. A pretty smart way of solving this exercise.
Really nice solution, but you should probably change the pattern you catch from "(\d*)(\D*)" to "(\d*)([a-zA-z]*)"
as now you catch every non digit character including spaces, tabs, special chars, instead of just letters like the question required.
for example is_a_valid_message('2^!') will return True instead of False in your case.