Bem vindo(a) à Touhou Wiki!

Módulo:MW.text

Fonte: Touhou Wiki
Revisão em 17h52min de 6 de março de 2016 por GrafZeppelin (discussão | contribs) (Criou a página com "-- This is just a helper library that implements some missing features from current Scribunto release local common = require("Module:Common") text = {} function text.trim...")
(dif) ← Revisão anterior | Revisão atual (dif) | Revisão seguinte → (dif)
Saltar para a navegação Saltar para a pesquisa

A documentação para este módulo pode ser criada na página Módulo:MW.text/doc

-- This is just a helper library that implements some missing features from current Scribunto release

local common = require("Module:Common")

text = {}

function text.trim(val)
  return tostring(val):gsub("^%s*(.-)%s*$", "%1")
end

function text.split(str, sep, lit)
  local pos = 1
  local t = {}
  if not common.isset(sep) or not common.isset(str) then return t end
    for s, e in function() return string.find(str, sep, pos) end do
    t[#t+1] = text.trim(string.sub(str, pos, s-1))
    pos = e+1
  end
  t[#t+1] = text.trim(string.sub(str, pos))
  return t
end

return text