for each in next

作者:夏雨芭蕉时间:2016-05-10 13:36:15 浏览量:

<%
Set objEXP = New RegExp
     objEXP.Global = True      '   设置全局替换。  
     objEXP.IgnoreCase = True  '   设置是否区分大小写。  
dim strVal:strVal="caseAjax,3,10"
Dim arr : arr = expSplit(strVal,"\s*,\s*") '正则逗号,
echo Ubound(arr,1)    '2
for each i in arr
     echo i
next     'ASP的正则expSplit
     Private Function expSplit(ByVal a,ByVal b)
          Dim Match, SplitStr
                         SplitStr = a
          Dim Sp : Sp = "#taihom.com@"        
               For Each Match in expMatch(a,b)
                    SplitStr = Replace( SplitStr , Match.value , Sp ,1,-1,0) '将逗号,替换成sp   
               Next
                    ' SplitStr=caseAjax#taihom.com@3#taihom.com@10
          expSplit = Split( SplitStr, Sp)
     End Function
   
     '在 a中找到 b的match,如果没有找到返回Empty
     Private Function expMatch(ByVal a,ByVal b)
          objEXP.Pattern = b                      '   设置模式。
          Set expMatch = objEXP.Execute(a)      '   执行搜索。  
     End Function   
   
     sub echo(str)
          response.Write str&"<br/>"
     end sub%>    结果:
2   --数组上限 2个,即0,1,2 共3个
caseAjax --数组第0个
3  --数组第1个
10 --数组第2个========================================
下面是简单的for each 例子
<%
dim saveitem
saveitem=array("Name","address","telephone","fax","QQ","mobile","webpage","email","postCode","birthday")function savedata()
     for each item in saveitem
          response.write item&"<br/>"
     next
end functionCall savedata()%>   
结果:
Name
address
telephone
fax
QQ
mobile
webpage
email
postCode
birthday

Copyright © 2016 Allister All Rights Reserved