Module:Utilities: Difference between revisions

Jump to navigation Jump to search
Sur (talk | contribs)
m add_space_before_cap
added function to split pascal into separate words
Line 48: Line 48:
end
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")
   
    -- Return the result with a capital letter followed by another capital and lowercase letters split
    return result:gsub("(%u)(%u%l)", " %1%2")
end
return p
return p