代码:<%
Html = "http://count.abc.com/click.asp内容8888http://count.abc.com/click.asp"
parts = split(Html, "count")
parts1 = split(parts(1), "click")
parts1l = split(parts1(1), ".asp")
%>
<%=parts(2)%>'----------------我想用parts(2)来判断是否有第二个"count"存在,代码要怎么写.哪位高手来帮忙下.if parts(2)没有内容"count" then执行内容一
elseif parts(2)有内容"count" then 执行内容二end if ------------------------------------------正确的写法是什么呢...........

解决方案 »

  1.   

    asp可以用instr
    instr($a,$b)<>0表示,$a中包含$b
      

  2.   

    split函数的理解问题,split是用来按指定字符来划分字符串的,返回值是数组,例如www.sohu.com/1/2/3/3/1.htm,如果你执行url.split('//'),返回就是就是一个数组Arr,Arr(0)='www.sohu.com',Arr(1)=1,Arr(2)= 2 . .......,如果你要判断指定的字符或字符串是否存在,VBS可以用InStr,JS用Sunstring
      

  3.   

    js里判断是否存在的方法str.indexOf('count') 返回的是count在str中的位置, 如果不存在 则返回-13楼说的Substring(应该是他的笔误)是这样用的str.subString(4,7)返回str字符串第4至第7个字符, 并不是判断是否存在的方法.楼主说的split是将字符串分割, 比如:var test = "3,5,a";
    var temp = test.split(',');
    //此时temp[0]:3   temp[1]:5   temp[2]:"a"
    也无法判断是否存在
      

  4.   

    <% 
    Html = "http://count.abc.com/click.asp内容8888http://count.abc.com/click.asp" 
    'Html = "http://count.abc.com/click.asp内容8888http://coun.abc.com/click.asp" 
    parts = split(Html, "count") 
    %><%="parts长=" & UBound(parts) & "<br>"%><%
    'show parts -- start
    dim i
    for i=0 to UBound(parts)
    %>
    <%="parts(i)" & parts(i) &"<br>"%>
    <%
    next
    %>
    <%="<hr>"%>
    <%
    'show parts -- end
    %><%if UBound(parts)>=2 then %>
    <%="parts(2)有内容""count"""%>
    <%else%>
    <%="无parts(2)=无第二个""count"""%>
    <%end if%>
    --IIS5
      

  5.   

    更正一句:
    <%="parts长=" & UBound(parts) & "<br>"%>
    为:
    <%="parts长=" & UBound(parts)+1 & "<br>"%>