1
Fork 0
satellite/dotfiles/neovim/lua/my/helpers/string.lua

14 lines
278 B
Lua
Raw Normal View History

2023-09-22 18:37:24 +02:00
local M = {}
function M.split(text, sep)
---@diagnostic disable-next-line: redefined-local
local sep, fields = sep or ":", {}
local pattern = string.format("([^%s]+)", sep)
text:gsub(pattern, function(c)
fields[#fields + 1] = c
end)
return fields
end
return M