Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
这个函数在Lua中做什么? 函数splitSat(str、pat、max、regex) 帕特=帕特或“\n”--巴斯克达赞助人 max=max或#str 局部t={} 局部c=1 如果#str==0,则 返回{'} 结束 如果#pat==0,则 归零 结束 如果max==0,则 返回str 结束 重复 本地s,e=str:find(pat,c,而不是regex)——Dentro del string str,busca el pator pat desde la posicion c --这是我们的财务数字 max=max-1 如果s和max0,那么——这是字符串的最长长度,这是0 t[#t+1]=str:sub(c) 其他价值观 t[#t+1]=“创建一个空 结束 其他的 如果#(str:sub(c,s和s-1))>0,则--Si la longitud de la porcion de string str entre c y s t[#t+1]=str:sub(c、s和s-1) 其他的 t[#t+1]=“创建一个具有空值的表 结束 结束 c=e和e+1或#str+1 直到s或最大值不小于0 返回t 结束_Lua - Fatal编程技术网

这个函数在Lua中做什么? 函数splitSat(str、pat、max、regex) 帕特=帕特或“\n”--巴斯克达赞助人 max=max或#str 局部t={} 局部c=1 如果#str==0,则 返回{'} 结束 如果#pat==0,则 归零 结束 如果max==0,则 返回str 结束 重复 本地s,e=str:find(pat,c,而不是regex)——Dentro del string str,busca el pator pat desde la posicion c --这是我们的财务数字 max=max-1 如果s和max0,那么——这是字符串的最长长度,这是0 t[#t+1]=str:sub(c) 其他价值观 t[#t+1]=“创建一个空 结束 其他的 如果#(str:sub(c,s和s-1))>0,则--Si la longitud de la porcion de string str entre c y s t[#t+1]=str:sub(c、s和s-1) 其他的 t[#t+1]=“创建一个具有空值的表 结束 结束 c=e和e+1或#str+1 直到s或最大值不小于0 返回t 结束

这个函数在Lua中做什么? 函数splitSat(str、pat、max、regex) 帕特=帕特或“\n”--巴斯克达赞助人 max=max或#str 局部t={} 局部c=1 如果#str==0,则 返回{'} 结束 如果#pat==0,则 归零 结束 如果max==0,则 返回str 结束 重复 本地s,e=str:find(pat,c,而不是regex)——Dentro del string str,busca el pator pat desde la posicion c --这是我们的财务数字 max=max-1 如果s和max0,那么——这是字符串的最长长度,这是0 t[#t+1]=str:sub(c) 其他价值观 t[#t+1]=“创建一个空 结束 其他的 如果#(str:sub(c,s和s-1))>0,则--Si la longitud de la porcion de string str entre c y s t[#t+1]=str:sub(c、s和s-1) 其他的 t[#t+1]=“创建一个具有空值的表 结束 结束 c=e和e+1或#str+1 直到s或最大值不小于0 返回t 结束,lua,Lua,我想知道这个函数在做什么。我知道它是一种用字符串和图案组成的表格。特别是我想知道*t[#t+1]=str:sub(c,s和s-1)*在做什么。从我得到的信息来看,它将一个长字符串分割成与特定模式匹配的子字符串,并忽略模式之间的所有内容。例如,它可能将字符串11aa22与模式\d\d匹配,从而生成表[“11”,“22”] t[#t+1]=在表的末尾插入一个值t,它与表相同。插入(t,) #t返回数组的长度(即具有连续数字索引的表),例如,#[1,2,3]==3 str:sub(c、s和s-1)利用

我想知道这个函数在做什么。我知道它是一种用字符串和图案组成的表格。特别是我想知道
*t[#t+1]=str:sub(c,s和s-1)*
在做什么。

从我得到的信息来看,它将一个长字符串分割成与特定模式匹配的子字符串,并忽略模式之间的所有内容。例如,它可能将字符串
11aa22
与模式
\d\d
匹配,从而生成表
[“11”,“22”]

t[#t+1]=
在表的末尾插入一个值
t
,它与
表相同。插入(t,)

#t
返回数组的长度(即具有连续数字索引的表),例如,
#[1,2,3]
==
3

str:sub(c、s和s-1)
利用了luas的许多特性<如果
s
不是
nil
,则code>s和s-1的计算结果为
s-1
,否则为nil。如果
s
nil

  • 10和10-1
    =
    9
  • 10-1
    =
    9
  • nil和nil-1
    ==
    nil
  • nil-1
    ->引发错误
str:sub(a,b)
只返回从
a
开始到
b
结束的子字符串(
a
b
是数字索引)


(“abcde”):sub(2,4)
=“bcd”

根据我得到的结果,它将一个长字符串拆分为与某个模式匹配的子字符串,并忽略模式之间的所有内容。例如,它可能将字符串
11aa22
与模式
\d\d
匹配,从而生成表
[“11”,“22”]

t[#t+1]=
在表的末尾插入一个值
t
,它与
表相同。插入(t,)

#t
返回数组的长度(即具有连续数字索引的表),例如,
#[1,2,3]
==
3

str:sub(c、s和s-1)
利用了luas的许多特性<如果
s
不是
nil
,则code>s和s-1的计算结果为
s-1
,否则为nil。如果
s
nil

  • 10和10-1
    =
    9
  • 10-1
    =
    9
  • nil和nil-1
    ==
    nil
  • nil-1
    ->引发错误
str:sub(a,b)
只返回从
a
开始到
b
结束的子字符串(
a
b
是数字索引)


(“abcde”):sub(2,4)
=“bcd”

我从未与Lua合作过。于是我抬起头来。因为这些评论是用西班牙语写的,我用谷歌翻译来了解它们的意思。我从来没有和Lua合作过。于是我抬起头来。因为这些评论是用西班牙语写的,所以我用谷歌翻译来了解它们的意思。
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