function splitSat(str, pat, max, regex)
pat = pat or "\n" --Patron de búsqueda
max = max or #str
local t = {}
local c = 1
if #str == 0 then
return {""}
end
if #pat == 0 then
return nil
end
if max == 0 then
return str
end
repeat
local s, e = str:find(pat, c, not regex) -- Dentro del string str, busca el patron pat desde la posicion c
-- guarda en s el numero de inicio y en e el numero de fin
max = max - 1
if s and max < 0 then
if #(str:sub(c)) > 0 then -- Si la longitud de la porcion de string desde c hasta el final es mayor que 0
t[#t+1] = str:sub(c)
else values
t[#t+1] = "" --create a table with empty
end
else
if #(str:sub(c, s and s - 1)) > 0 then -- Si la longitud de la porcion de string str entre c y s
t[#t+1] = str:sub(c, s and s - 1)
else
t[#t+1] = "" --create a table with empty values
end
end
c = e and e + 1 or #str + 1
until not s or max < 0
return t
end
この機能が何をしているのか知りたいです。私はそれが文字列とパターンを取る一種のテーブルを作ることを知っています。特に*t[#t+1] = str:sub(c, s and s - 1)*
が何をしているのですか?この関数はLuaで何をしていますか?
("abcde"):sub(2,4)
==a
でtartingとb
(a
とb
ている数値指標)で終わります。だから私はhttps://stackoverflow.com/questions/17974622/what-does-mean-in-luaを見上げた。コメントはスペイン語で書かれているので、私はGoogle翻訳を使ってその意味を理解しました。 –