LUA適用カットには、特殊な開始文字列、終了文字列の内容が含まれます.
2291 ワード
適用カットには、特殊な開始文字列、終了文字列の内容が含まれます.
-- _sStr(string) _sFir(string) _sFin(string)
-- _speKey(string) key
-- "@ # " ("@ # ","@","#") sResidueContent = " " tTakeOutList = {{@ #}}
function getTargetStr(_sStr,_sFir,_sFin,_speKey)
if _sStr then
local strCopy = _sStr or ""
local nFsindex, nFeindex = string.find(strCopy, _sFir) --
local nSsindex, nSeindex = string.find(strCopy, _sFin) --
local strt1 = "" --
local strt2 = "" --
local strt3 = "" --
local tTakeOutList = {} --
local sResidueContent = ""
if (nFsindex ~= nil and nSsindex ~= nil) then
while(nFsindex ~= nil and nSsindex ~= nil) do
--
strt2 = getMmongStr(strCopy,_sFir,_sFin)
if strt2 ~= "" then
strRemain = _sFir..strt2.._sFin
table.insert(tTakeOutList,strRemain)
end
--
if _speKey then
strt1 = strt1..string.sub(strCopy, 1, nFsindex-1).._speKey
else
strt1 = strt1..string.sub(strCopy, 1, nFsindex-1)
end
--
strt3 = string.sub(strCopy, nSeindex+1)
--
strCopy = strt3
--
nFsindex, nFeindex = string.find(strCopy, _sFir)
nSsindex, nSeindex = string.find(strCopy, _sFin)
end
sResidueContent = strt1..strt3 --
else
sResidueContent = strCopy --
end
return sResidueContent,tTakeOutList -- , ( )
else
return ""
end
end
-- _sStr(string) _sFir(string) _sFin(string)
function getMmongStr(_sStr,_sFir,_sFin)
local sNew = ""
local index1 = string.find(_sStr,_sFir)
local index2 = string.find(_sStr,_sFin)
if index1 and index2 then
sNew = string.sub(_sStr,index1+1,index2-1)
end
return sNew
end