Will Alphanumeric contain _ and space?
I came here wondering why \w
in regex includes underscore, I had assumed \w
meant alphanumeric [A-Za-z0-9]
but that is not the case in regex python.
Turns out \w
includes underscore as well as letters with diacritics, letters from other scripts, etc. Such as the German letter "ö" in "schön".
So now I've learned to use the longform [A-Za-z0-9]
if I wanted to be specific.
Alphanumeric characters by definition only comprise the letters A to Z and the digits 0 to 9. Spaces and underscores are usually considered punctuation characters, so no, they shouldn't be allowed.
If a field specifically says "alphanumeric characters, space and underscore", then they're included. Otherwise in most cases you generally assume they're not.
Alphanumeric characters are A to Z, a to z and 0 to 9