AHK高级字符串函数,新人勿进
使用方法和使用示例均在代码中,请自行查看!
;e.g. ;MsgBox, % JEE_StrPad("abcdefghij", ",") ;a,b,c,d,e,f,g,h,i,j ;MsgBox, % JEE_StrPad("abcdefghij", ",", 3) ;abc,def,ghi,j ;MsgBox, % JEE_StrPad("abcdefghij", ",", 3, "R") ;a,bcd,efg,hij ;MsgBox, % JEE_StrPad("abcdefghij", ",", 3, "O")[2] ;def ;vSep: separator ;vBlockLen: length of character blocks ;vOpt: R: from which end, start from right ;vOpt: O: return object (vSep is ignored) ;JEE_StrSlice JEE_StrPad(vText, vSep, vBlockLen:=1, vOpt:="") { if (vText = "") return if InStr(vOpt, "R") vOffset := vBlockLen - Mod(StrLen(vText), vBlockLen) else vOffset := 0 if InStr(vOpt, "O") { oArray := [] oArray.SetCapacity(StrLen(vText)//vBlockLen) vTemp := "" Loop, Parse, vText { if (Mod(A_Index + vOffset, vBlockLen) = 0) oArray.Push(vTemp A_LoopField), vTemp := "" else vTemp .= A_LoopField } if !(vTemp = "") oArray.Push(vTemp) return oArray } VarSetCapacity(vOutput, StrLen(vText)*2+(StrLen(vText)//vBlockLen)*StrLen(vSep)*2) Loop, Parse, vText { if (Mod(A_Index + vOffset, vBlockLen) = 0) vOutput .= A_LoopField vSep, vDoCrop := 1 else vOutput .= A_LoopField, vDoCrop := 0 } if vDoCrop return SubStr(vOutput, 1, -StrLen(vSep)) else return vOutput }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
牛逼了,我的哥!