Which language? There are some differences.
Is there a range to the number of digits? or is it anything from one digit to (anything)?
I'd think it'd be more like ^\d+[0-4]$ the ^ is beginning of the line, one or more digit followed by a 0, 1, 2, 3, 4, which would be the last character.
or .*[0-4]$ which would be anything on the line, with a 0, 1, 2, 3, 4 being the last character of the line.
(some) SQL uses the underscore for a single character match, most scripts & languages use the dot to match anything (some with optional match of a line feed / or return), the + is one or more, * is zero or more
Then you can make it "greedy" (in most languages/scripts/utilities) by following the quantifier with a "?"
... and if you needed to capture the number, you'll need to encapsulate some or all of the REGEX with parentheses