aboutsummaryrefslogtreecommitdiff
path: root/lua/denote/util.lua
blob: bd237eb05e304fef2f65e83ce5ae3ba5c989e05b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
local M = {}

function M.splitspace(str)
	local chunks = {}
	for substring in str:gmatch("%S+") do
		table.insert(chunks, #chunks, substring)
	end
	return chunks
end

function M.splitstring(str, delim)
	local items = {}
	local fulldelim = nil
	if delim == "." or delim == "-" then
		fulldelim = "%" .. delim
	else
		fulldelim = delim
	end
	print("fulldelim: ", fulldelim)
	str = str .. delim
	for w in str:gmatch("(.-)" .. fulldelim) do
		items[#items + 1] = w
	end
	return items
end

return M