mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-14 01:50:27 +00:00
26 lines
455 B
Lua
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
|