harpoon/lua/harpoon/utils.lua
2023-12-06 16:23:40 -08:00

26 lines
455 B
Lua

local M = {}
function M.trim(str)
return str:gsub("^%s+", ""):gsub("%s+$", "")
end
function M.remove_duplicate_whitespace(str)
return str:gsub("%s+", " ")
end
function M.split(str, sep)
if sep == nil then
sep = "%s"
end
local t = {}
for s in string.gmatch(str, "([^" .. sep .. "]+)") do
table.insert(t, s)
end
return t
end
function M.is_white_space(str)
return str:gsub("%s", "") == ""
end
return M