Editing Module:UtilitiesGive feedback
Jump to navigation
Jump to search
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 73: | Line 73: | ||
-- when a string doesn't have localization, it can outputted as add_space_before_cap(unlocalized_key) | -- when a string doesn't have localization, it can outputted as add_space_before_cap(unlocalized_key) | ||
function p.add_space_before_cap(str) | function p.add_space_before_cap(str) | ||
return str:gsub("(%u)", function(c) | |||
return " " .. c | |||
end, 2) | |||
end | |||
function p.split_pascal(str) | |||
-- Insert a space before each capital letter (except the first one) that is followed by a lowercase letter | |||
local result = str:gsub("(%l)(%u)", "%1 %2") | local result = str:gsub("(%l)(%u)", "%1 %2") | ||
-- Return the result with a capital letter followed by another capital and lowercase letters split | |||
return result:gsub("(%u)(%u%l)", " %1%2") | return result:gsub("(%u)(%u%l)", " %1%2") | ||
end | end | ||