By reading the documentation here it seems to me that
re.compile(r'^[-\w]+$')
would just search whether there was any character that is alphanumeric, an underscore, or a hyphen. But really this returns a match only if all the characters fit that description (ie, it fails if there is a space or a dollar sign or asterisk, etc).
I don't really understand how this is working to check all of the characters when it says:
"The '*', '+', and '?' qualifiers are all greedy; they match as much text as possible.".
Doesn't that mean that if there's a space character in at the 6th character it'll match as much as possible and then stop and return the match it found in the first 5 characters (rather than saying "sorry, I found nothing" essentially when it reaches a non-match).
Thanks in advance (I'm such a noob at regex and each time I learn it again I just get confused).