截取法提取两个字符串之间的内容
//截取法提取 Function 取中间文本(str,StrA,StrB) If UTF8.InStr(1, str, StrA)>0 and utf8.instr(1,str,StrB) > 0 Then Dim m=utf8.instr(1,Str,StrA) Dim n=utf8.instr(m,Str,StrB) 取中间文本=utf8.mid(str,m+utf8.len(StrA),n-m-utf8.len(StrA)) End If End Function //分割法提取字符串 Function 取中间文本2(str, StrA, StrB) If UTF8.InStr(1, str, StrA) > 0 and UTF8.InStr(1, str, StrB) > 0 Then Dim arr_A=split(str,StrA) Dim arr_B=split(arr_A(1),StrB) 取中间文本2=arr_B(0) end if End Function //批量取中间文本 Dim arr=GetStrArr("如果(想要)写成一行(代码),那么就(可以)用冒号连接","(",")") For Each k In arr TracePrint k Next Function GetStrArr(str, StrA, StrB) If UTF8.InStr(1, str, StrA) > 0 and UTF8.InStr(1, str, StrB) > 0 Then Dim str_arr=array() Dim n=0 Dim arr_A=split(str,StrA) Dim arr_B For i = 1 To UBOUND(arr_A) If InStr(1,arr_A(i),StrB) > 0 Then arr_B = Split(arr_A(i), StrB) str_arr(n) = arr_B(0) n=n+1 End If Next GetStrArr=str_arr end if End Function //只取数字 TracePrint GetNum("如果7991312_ba@326d1b都是a2a693880a25f%1330b955526连接") Function GetNum(str) Dim Num For i = 1 To UTF8.Len(str) If IsNumeric(utf8.StrGetAt(str,i)) Then Num=Num&utf8.StrGetAt(str,i) End If Next GetNum=Num End Function //只取字母 TracePrint GetZm("如果7991312_ba@326d1b都是a2a693880a25f%1330b955526连接") Function GetZm(str) Dim zm For i = 1 To UTF8.Len(str) If 64 < CInt(Asc(UTF8.StrGetAt(str, i))) < 91 or 96 < CInt(Asc(UTF8.StrGetAt(str, i))) < 123 Then zm=zm&utf8.StrGetAt(str,i) End If Next GetZm=zm End Function //只取汉字 TracePrint GetCN("如果7991312_ba@326d1b都是a2a693880a25f%1330b955526连接") Function GetCN(str) Dim CN For i = 1 To UTF8.Len(str) If Len(UTF8.StrGetAt(str, i)) = 3 Then CN=CN&UTF8.StrGetAt(str, i) End If Next GetCN=CN End Function Function 取左边(str,分隔符)//取左边 Dim MyString = Split(str,分隔符) 取左边=MyString(0) End Function Function 取右边(str,分隔符) //取中间右边 Dim MyString = Split(str,分隔符) 取右边=MyString(1) End Function //只取数字[正则] import"shanhai.lua" Dim str="如果7991312_ba@326d1b都是a2a693880a25f%1330b955526连接" dim arr= shanhai.RegexFind(str,"%d+") TracePrint join(arr,"") //只取字母[正则] import"shanhai.lua" Dim str="如果7991312_ba@326d1D都是a2a693880a25f%1330b955526连接" dim arr= shanhai.RegexFind(str,"%a+") TracePrint join(arr,"") //只取汉字[正则] import"shanhai.lua" Dim str="如果7991312_ba@326d1D都是a2a693880a25f%1330b955526连接" dim arr= shanhai.RegexFind(str,"[\128-\254]+") TracePrint join(arr,"")