I came up with a little more complex code. This should handle decimal numbers and still support reformatting multiple numbers in a string. It works by nesting
string:gsub() calls in replacement functions. The base function seeks out all numbers and calls
SplitDecimal() to modify them.
SplitDecimal()'s entire purpose is for decimal number support and will only grab the integer section of a decimal number, calling
AddCommas() on it and leaving the rest alone.
AddCommas() is what inserts the locale-dependent separator as stored in
LARGE_NUMBER_SEPERATOR. This global is what's used in the Default UI code for
BreakUpLargeNumbers().
Lua Code:
local ReformatNumberString; do
local AddCommas(pre,post) return pre..post:reverse():gsub("(%d%d%d)","%1"..LARGE_NUMBER_SEPERATOR):reverse(); end
local SplitDecimal(str) return str:gsub("^(%d)(%d+)",AddCommas); end
function ReformatNumberString(str) return str:gsub("[%d%.]+",SplitDecimal); end
end