I need a regular expression to match an identifier in the following format
123
or
123-45
There can be any number of digits before the hyphen. The problem right now is that my expression matches 123-, and I don’t need it too much (a hyphen is optional, but if it is present, then there MUST be at least one digit after it).
I tried
^\d+[-\d+]?
and ^\d+[-\d]?\d*but do not work.
source
share