I'm new to python programming and doing some challenges to improve my coding; I encounter the following regular expression: (r"^[a-zA-Z][\w_]{2,23}[^_]$").
Doing some research, I understand this:
r"
= The expression is a raw string (not sure what this mean entirely)
^[a-zA-Z]
= This tells me that the string must start with a letter
[\w_]{2,23}
= the body of the string from val[2]
to val[23]
must be alphanumeric
[^_]$
= the end must be an underscore
If my research is correct, I don't understand why the [\w_]
contains an underscore on it. I thought for alphanumerics must be only [\w].
If I'm wrong, help me to clarify it.