From 720dc2131f7fc0d4863e20326b9308feaf7e323e Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Thu, 25 Nov 2021 17:37:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=BB=99=E9=BB=98=E8=AE=A4string=E5=BA=93?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E4=B8=A4=E4=B8=AA=E6=96=B9=E6=B3=95repD?= =?UTF-8?q?=E5=92=8CsArg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/stringExtend.lua | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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']='%',