Warning: You are not logged in. Once you make an edit, a temporary account will be created for you.
Learn more.
Log in or
create an account to continue receiving notifications after this account expires, and to access other features.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
| Latest revision |
Your text |
| Line 1: |
Line 1: |
| local p = {}; | | local p = {}; |
|
| |
| -- "Default %hero_name% Build" --> "Default Build", or "Default Build" with -1 or +1 for spaces
| |
| function p.remove_var(input, spaces)
| |
| -- spaces =
| |
| -- -1: also remove prefixed character
| |
| -- 0 or nil: no character
| |
| -- 1: postfixed character
| |
| -- Remove text between % and % including the %
| |
| local result = input:gsub("%%.-%%", "")
| |
|
| |
| -- If spaces == -1, remove the character before the removed section
| |
| if spaces ~= nil and spaces == -1 then
| |
| result = result:gsub("%s+%s*", "", 1) -- Removes the preceding space or character
| |
| -- If spaces == 1, remove the character after the removed section
| |
| elseif spaces ~= nil and spaces == 1 then
| |
| result = result:gsub("%s+", "", 1) -- Removes the postfixed space
| |
| end
| |
|
| |
| -- Trim any extra whitespace
| |
| result = result:gsub("^%s*(.-)%s*$", "%1")
| |
|
| |
| return result
| |
| end
| |
|
| |
|
| --round_to_significant_figures(12345.6789, 3) -- Output: 12300 | | --round_to_significant_figures(12345.6789, 3) -- Output: 12300 |