Actually, considering chomping was not done, the original
answer, /^\d$/ would be correct, unlike your
answer, which would never match, as there would always be
the trailing newline.
The fact that $ can match just before a trailing
newline makes cases like this "do what I mean".