How to increment taking into account preceding zeros?

Part of my macro reads the last number in a string (URL). This number is stored in a variable. Then the value of the variable is to be increased by 1 (set variable to variable + 1).

This works wonderfully if there are no preceding zeros:

1 → 2
123121 → 123122

How do I make it so that instead of

00004 → 5
0099 → 100

the following comes out?

00004 → 00005
0099 → 0100

Thanks for suggestions!

I solved this on my own:

Using the Set Variable to Text action action, I added the prefix 9 to my variable Page like this: %Variable%Prefix%%Variable%Page%. After incrementing the result, I applied a simple regular expression (\d{1})(\d*) and used the second capture group (number without the prefix) to move on.

You could always try the CalculateFormat token. See the wiki token:CalculateFormat [Keyboard Maestro Wiki]