You can use a pretty simple string pattern for this:
local license = license:gsub("0+([^0]+0*)$", "%1")
Basically, this matches as many zeroes as possible in a row, any number of non-zero characters, then any number of zeroes before the end of the string. It replaces all that with everything after the non-zero characters.
If you need to remove multiple isolated sets of zeroes (e.g. 10203), you’d have to loop this until there’s no zeroes. Here’s a sloppy example of how that could work:
local pattern = "0+([^0]+0*)$"
while license:match(pattern) do
license = license:gsub(pattern, "%1")
end
There’s probably a better way to do this, but this is what I came up with off the top of my head.
Edit: Here’s another way simpler solution:
license = license:gsub("0+([^0])", "%1")
Removes any zeroes that have something besides a zero after them.
Those are two string patterns. The 0+ represents any number of zeroes (+ is for 1 or more). The parentheses around the [^0] match it as a capture, and [^0] matches any non-zero (^ negates the pattern) character. In the second pattern, %1 just represents the replacement string. %1, %2, %3, etc. all represent a capture, which is what the parentheses from earlier were for. So, basically, it takes any number of zeroes and then a non-zero character, replacing it with just that non-zero character.