Jump to content

Module:US elections imagemap/utils

Permanently protected module
From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by MusikBot II (talk | contribs) at 03:54, 28 September 2021 (Protected "Module:US elections imagemap/utils": High-risk template or module: 421 transclusions (more info) ([Edit=Require autoconfirmed or confirmed access] (indefinite))). The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

local p = {}

function p.stripspaces(str)
	return str:gsub("^%s*(.-)%s*$", "%1") -- trim spaces
end

function p.split(str, sep) -- split string by separator and return table
  sep = sep or "%s"
  local parts = {}
  for word in string.gmatch(str, "[^" .. sep .. "]+") do parts[#parts+1] = p.stripspaces(word) end
  return parts
end

return p