The following regex should work for most flavors:
(?:_.*|\d*)$
We match either _
followed by anything until the end of the string. Or we match a bunch of digits until the end of string. (The end of string is represented by the anchor $
)
Some flavors might choke upon the ?:
which is really just an optimization. You can as well leave it out.