有个字符串
abc="<td width=80% valign=top><a href=SingleDetailed.asp?i=B%11%7CI2%01n%3DV%5B%5BdXB&p=06><span class=RedStrong>深圳市鑫协成科技有限公司</span></a><br><font color=885500"
现在要在里面找出"深圳市鑫协成科技有限公司"字符串,该字符串的开始位置是"td width=80%"后面的第3个">"的后一位(就是“深”字的位置),结束位置是"<font color=885500"前面的第3个"<"的前一位(就是“司”字的位置).
请教能不能用instr()或别的涵熟来表示“某个字符在另一个字符中第N次出现的位置”?
谢谢!

解决方案 »

  1.   

    dim abc as string
    dim tmpA as string
    dim arrA() as string
    dim strB as string
    ...
    abc="="<td width=80% valign=top......"
    strB="深圳市鑫协成科技有限公司"  '是不是做广告???
    tmpA=left(abc,instr(abc,strB)-1)
    arrA=split(tmpA,">")
    debug.print strB & "出现在第" & ubound(arrA) & "个'<'之后" 。
      

  2.   

    我觉得你用计数器比较好。Dim strOrigin As String
    Dim strFound As String
    Dim iCount as Integer
    Dim x As IntegerFor x=1 To Len(strOrigin)
    Select Case Mid(strOrigin, x, 1)
    Case "<"
      iCount=iCount+1
    Case ">"
      iCount=iCount-1
    Case Else
      If iCount=0 Then strFound = strFound & Mid(strOrigin, x, 1)
    End Select
    Next x当然你自己要稍微处理一下。
    这样的代码可以处理所有<>外的内容
      

  3.   

    VBscript有这个
    Regular Expression (RegExp) Object
      

  4.   

    谢谢楼上两位大侠!
    TO pigpag(Pigpag) :能不能只用一个函数来表示“某个字符在另一个字符中第N次出现的位置”?
    TO flyingscv(zlj):能不能说详细点?再一次谢谢!
      

  5.   

    返回值是所求位置,参数 N 是出现次数
    public function InStrN(N as integer, byval str1 as string, byval str2 as string) as integer
    dim i as integer, p as integer
    Do until i = N or p = 0
    p = P + 1
    p = instr(p, str1,str2)
    if p then 
      i = i + 1
    end if
    loop
    InstrN = p
    N = i
    end function