in reply to When greedy constructs do battle, can I choose the winner?

While I like the idea of bullying regexes battling over lunch money, I don't know how you can pull that off...

But what I'd suggest is just doing

$running_total =~ s/(\d{0,4}[1-9])0*$/$1/;
I think that should get you as many digits as possible up to 5 before the trailing 0's, without anyone's lunch money being at risk. :)

Mike