diff --git a/Zframework/stringExtend.lua b/Zframework/stringExtend.lua index 35f5e836..50399f23 100644 --- a/Zframework/stringExtend.lua +++ b/Zframework/stringExtend.lua @@ -2,9 +2,25 @@ local data=love.data local STRING={} local assert,tostring,tonumber=assert,tostring,tonumber local int,format=math.floor,string.format -local find,sub,upper=string.find,string.sub,string.upper +local find,sub,gsub,upper=string.find,string.sub,string.gsub,string.upper local char,byte=string.char,string.byte +--"Replace dollars", replace all $n with ... +function string.repD(str,...) + local l={...} + for i=#l,1,-1 do + str=gsub(str,'$'..i,l[i]) + end + return str +end + +--"Scan arg", scan if str has the arg (format of str is like "-json -q", arg is like "-q") +function string.sArg(str,switch) + if find(str.." ",switch.." ")then + return true + end +end + do--function STRING.shiftChar(c) local shiftMap={ ['1']='!',['2']='@',['3']='#',['4']='$',['5']='%',