In RegEx, the
$ asserts the end of a string or line. When used in
re.match() it asserts the end of the string by default, unless the last
character is a newline symbol (
\n). Then it asserts the end of the string
before the newline. Thus the first regex check doesn't filter valid
id_shorts ending in a newline, which it should.
Using re.fullmatch() instead fixes this issue, making the
unnecessary as well.
Next to adding a test for this behaviour this commit also simplifies the check for an alphabetical character at the start of the id_short. And although both checks could also be merged into one, they are left separate to be able to report more accurate errors.